Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit 37e4346

Browse files
committed
完成个人中心功能:重置密码、修改个性签名
1 parent 6040fd6 commit 37e4346

File tree

28 files changed

+742
-82
lines changed

28 files changed

+742
-82
lines changed

app/src/main/java/com/rae/cnblogs/MainActivity.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.rae.cnblogs.basic.AppFragmentAdapter;
2222
import com.rae.cnblogs.basic.BasicActivity;
2323
import com.rae.cnblogs.basic.rx.AndroidObservable;
24+
import com.rae.cnblogs.basic.rx.DefaultEmptyObserver;
2425
import com.rae.cnblogs.blog.CnblogsService;
2526
import com.rae.cnblogs.dialog.DefaultDialogFragment;
2627
import com.rae.cnblogs.dialog.VersionDialogFragment;
@@ -37,6 +38,8 @@
3738

3839
import org.greenrobot.eventbus.EventBus;
3940

41+
import java.util.concurrent.TimeUnit;
42+
4043
import butterknife.BindView;
4144

4245
@Route(path = AppRoute.PATH_APP_HOME)
@@ -59,11 +62,18 @@ protected void onCreate(Bundle savedInstanceState) {
5962
setContentView(R.layout.activity_main);
6063
mPresenter = new MainPresenterImpl(this);
6164
initTab();
62-
requestPermissions();
65+
66+
// 请求权限
67+
AndroidObservable.create(io.reactivex.Observable.timer(3, TimeUnit.SECONDS)).with(this).subscribe(new DefaultEmptyObserver<Long>() {
68+
@Override
69+
public void onNext(Long aLong) {
70+
requestPermissions();
71+
}
72+
});
6373
// 启动服务
6474
startService(new Intent(this, CnblogsService.class));
6575
if (BuildConfig.DEBUG) {
66-
debugLogin();
76+
// debugLogin();
6777
}
6878
}
6979

@@ -73,8 +83,8 @@ protected void onCreate(Bundle savedInstanceState) {
7383
*/
7484
protected void debugLogin() {
7585
String url = "cnblogs.com";
76-
String cookie = "6C55F7BB01F1C4CEBB563D4AAA2C9B85F2086BA23E5E11A3495B6EE49E72D6359E393DF59DD244681609EDBC14721F0EAD4F05C0FCBAB92FF93BDD5B12F9BE5CD82FB4E5F00884CD1BBEF4FC86E3F8FD389DF99D";
77-
String netCoreCookie = "CfDJ8KlpyPucjmhMuZTmH8oiYTPb0ZONfd-tyYB1msfyk5CLz4oTOh9cobYsipxyPxYkVzm2mi6FMT6FYZDDyzgMTY4FZX4gpjDyO8ZdiiX6M4VQOxYx37Fw4MbfIiHucZ0iJSu8YXBVT0No7b3819FyLA2uleoAYpdue6jD6J0xOdlHQPT5yU9f2OMVQY5fs87ZWSxzKFShb15j0rwKvedWA0w7kwDz5FYAQ7RLPpSDrhyWWGltt-rwSkySpJ7NsuS_Ffm2T6sq1c0TsVZLpIDBS8yXw0cuxNbQTMZJrIxHuFbl";
86+
String cookie = "A688D6A0971A93007FF8221C60E8E0FDB2866B1DF923C14422B361049C34194A5B1B25A7B3F72A002E41D100226A7F046D16B88F97412A6182FC4BF94F220D4A9236941DE58BCEFDA575CF4E3EB25A9D97BB7601";
87+
String netCoreCookie = "CfDJ8KlpyPucjmhMuZTmH8oiYTNfOPU2k5nMET16IOYR6efcY_FO5y_VQp8XjUgDHWE5RRYwTjaP2ccyMxNewY4lzaOFKZVXbJ3iw1xroxqbUsPY3tOneapdybk-LE44YvlnpDtbq9OG3Ed4IAbj1mvlilS_JwslUTpLEjjAxWx9DvTqenfu1HV2fEgaca_B0X1gLUnt81lTwiukd5XwnRo_jRETZ4r4XH4p8nK6nOnMCb8tBMXkFyPQQ-_Q16LIgHzU_-xnLa_jxTUYedi4QCWoAmAUNz59-xiuOSj9m58xi61hiljfeTxl-E9qjAUokzBbkQ";
7888
CookieManager cookieManager = CookieManager.getInstance();
7989
cookieManager.removeAllCookie();
8090
cookieManager.setCookie(url, ".CNBlogsCookie=" + cookie + "; domain=.cnblogs.com; path=/; HttpOnly");

module-home/src/main/java/com/rae/cnblogs/home/mine/MinePresenterImpl.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,7 @@ public void loadUserInfo() {
102102
}
103103

104104
getView().onLoadUserInfo(userInfo);
105-
106-
// 加载粉丝关注数量
107-
AndroidObservable
108-
.create(mFriendApi.getFriendsInfo(userInfo.getBlogApp()))
109-
.with(this)
110-
.subscribe(new ApiDefaultObserver<FriendsInfoBean>() {
111-
@Override
112-
protected void onError(String message) {
113-
getView().onLoadFansCount("0", "0");
114-
}
115-
116-
@Override
117-
protected void accept(FriendsInfoBean m) {
118-
getView().onLoadFansCount(m.getFans(), m.getFollows());
119-
}
120-
});
121-
105+
loadFansInfo(userInfo);
122106
// 刷新用户信息
123107
AndroidObservable
124108
.create(mUserApi.getUserInfo(userInfo.getBlogApp()))
@@ -148,6 +132,24 @@ protected void accept(UserInfoBean userInfoBean) {
148132
});
149133
}
150134

135+
private void loadFansInfo(UserInfoBean userInfo) {
136+
// 加载粉丝关注数量
137+
AndroidObservable
138+
.create(mFriendApi.getFriendsInfo(userInfo.getBlogApp()))
139+
.with(this)
140+
.subscribe(new ApiDefaultObserver<FriendsInfoBean>() {
141+
@Override
142+
protected void onError(String message) {
143+
getView().onLoadFansCount("0", "0");
144+
}
145+
146+
@Override
147+
protected void accept(FriendsInfoBean m) {
148+
getView().onLoadFansCount(m.getFans(), m.getFollows());
149+
}
150+
});
151+
}
152+
151153

152154
/**
153155
* 检查是否有新的意见反馈回复消息
@@ -177,6 +179,9 @@ public void onEvent(UserInfoChangedEvent event) {
177179
// 重新加载数据
178180
if (event.isRefresh()) {
179181
loadUserInfo();
182+
} else {
183+
getView().onLoadUserInfo(event.getUserInfo());
184+
loadFansInfo(event.getUserInfo());
180185
}
181186
}
182187

module-middleware/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
android:configChanges="keyboardHidden|orientation|screenSize"
2929
android:exported="true"
3030
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
31+
<activity android:name="com.rae.cnblogs.activity.ActionResultActivity" />
3132

3233
</application>
3334

module-middleware/src/main/java/com/rae/cnblogs/AppRoute.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public final class AppRoute {
200200

201201
// 用户详情
202202
public static final String PATH_PERSONAL_DETAIL = "/user/info/detail";
203+
public static final String PATH_ACTION_RESULT = "/middleware/action/result";
203204

204205
/**
205206
* 初始化
@@ -242,6 +243,15 @@ public static void routeToWeb(Context context, String url) {
242243
ARouter.getInstance().build(PATH_WEB).withString("url", url).navigation(context);
243244
}
244245

246+
/**
247+
* 操作结果界面
248+
*
249+
* @param text 消息
250+
*/
251+
public static void routeToActionResult(Context context, String text) {
252+
ARouter.getInstance().build(PATH_ACTION_RESULT).withString(Intent.EXTRA_TEXT, text).navigation(context);
253+
}
254+
245255
/**
246256
* 用户反馈
247257
*/
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.rae.cnblogs.activity;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.support.annotation.Nullable;
6+
import android.widget.ImageView;
7+
import android.widget.TextView;
8+
9+
import com.alibaba.android.arouter.facade.annotation.Route;
10+
import com.rae.cnblogs.AppRoute;
11+
import com.rae.cnblogs.middleware.R;
12+
import com.rae.cnblogs.middleware.R2;
13+
14+
import butterknife.BindView;
15+
import butterknife.OnClick;
16+
17+
/**
18+
* 操作结果提示
19+
* Created by rae on 2018/12/20.
20+
* Copyright (c) https://github.com/raedev All rights reserved.
21+
*/
22+
@Route(path = AppRoute.PATH_ACTION_RESULT)
23+
public class ActionResultActivity extends SwipeBackBasicActivity {
24+
25+
@BindView(R2.id.tv_message)
26+
TextView mMessageView;
27+
28+
@BindView(R2.id.img_avatar)
29+
ImageView mAvatarView;
30+
31+
32+
@Override
33+
protected void onCreate(@Nullable Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.activity_action_result);
36+
setTitle(" ");
37+
mMessageView.setText(getIntent().getStringExtra(Intent.EXTRA_TEXT));
38+
39+
}
40+
41+
@Override
42+
public void onBackPressed() {
43+
super.onBackPressed();
44+
onHomeClick();
45+
}
46+
47+
@OnClick(R2.id.btn_ensure)
48+
public void onHomeClick() {
49+
AppRoute.routeToMain(this);
50+
finish();
51+
}
52+
}

module-middleware/src/main/java/com/rae/cnblogs/web/WebViewFragment.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
6161
}
6262
}
6363

64+
6465
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface", "JavascriptInterface"})
6566
@Override
6667
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
@@ -101,9 +102,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
101102
mWebView.setWebChromeClient(getWebChromeClient());
102103
mWebView.setWebViewClient(mRaeWebViewClient);
103104

104-
if (mWebView != null && mUrl != null) {
105-
loadUrl(mUrl);
106-
}
107105

108106
}
109107

@@ -125,6 +123,9 @@ public void onClick(View v) {
125123
});
126124
}
127125

126+
if (mWebView != null && mUrl != null) {
127+
loadUrl(mUrl);
128+
}
128129
}
129130

130131
@Override
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.v7.widget.FitWindowsLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="@color/white"
7+
android:fitsSystemWindows="true"
8+
android:orientation="vertical">
9+
10+
<android.support.v7.widget.Toolbar
11+
android:id="@+id/tool_bar"
12+
style="@style/AppToolBar"
13+
android:layout_width="match_parent"
14+
android:layout_height="@dimen/action_bar_height"
15+
android:layout_marginBottom="80dp"
16+
android:gravity="center"
17+
app:title="@null" />
18+
19+
<ImageView
20+
android:id="@+id/img_avatar"
21+
android:layout_width="100dp"
22+
android:layout_height="100dp"
23+
android:layout_gravity="center"
24+
android:scaleType="centerInside"
25+
android:src="@drawable/ic_success" />
26+
27+
<TextView
28+
android:id="@+id/tv_message"
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
android:layout_marginStart="60dp"
32+
android:layout_marginTop="36dp"
33+
android:layout_marginEnd="60dp"
34+
android:gravity="center"
35+
android:text="@string/title"
36+
android:textColor="@color/ph1"
37+
android:textSize="18sp"
38+
android:textStyle="bold" />
39+
40+
<Space
41+
android:layout_width="match_parent"
42+
android:layout_height="0dp"
43+
android:layout_weight="1" />
44+
45+
<Button
46+
android:id="@+id/btn_ensure"
47+
android:layout_width="match_parent"
48+
android:layout_height="42dp"
49+
android:layout_gravity="center"
50+
android:layout_marginStart="60dp"
51+
android:layout_marginEnd="60dp"
52+
android:layout_marginBottom="90dp"
53+
android:background="@drawable/bg_btn_default"
54+
android:text="返回首页"
55+
android:textColor="@color/ph1"
56+
android:textSize="16sp" />
57+
58+
</android.support.v7.widget.FitWindowsLinearLayout>
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false">
4+
<shape>
5+
<corners android:radius="@dimen/default_radius" />
6+
<solid android:color="#bebebe" />
7+
</shape>
8+
</item>
9+
<item android:state_pressed="true">
10+
<shape>
11+
<gradient android:centerColor="#FF67D3FB" android:endColor="#FF3BA7EE" android:startColor="#FF67D3FB" />
12+
<corners android:radius="@dimen/default_radius" />
13+
</shape>
14+
</item>
15+
<item>
16+
<shape>
17+
<gradient android:endColor="#FF3BA7EE" android:startColor="#FF67D3FB" />
18+
<corners android:radius="@dimen/default_radius" />
19+
</shape>
20+
</item>
21+
</selector>

module-resource/src/main/res/drawable/public_button_login.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false">
4+
<shape>
5+
<corners android:radius="20dp" />
6+
<solid android:color="#7c7c7c" />
7+
</shape>
8+
</item>
39
<item android:state_pressed="true">
410
<shape>
511

612
<corners android:radius="20dp" />
7-
<solid android:color="#67D3FB" />
13+
<gradient android:centerColor="#FF67D3FB" android:endColor="#FF3BA7EE" android:startColor="#FF67D3FB" />
814
</shape>
915
</item>
1016
<item>

module-sdk/src/main/java/com/rae/cnblogs/sdk/api/ApiUrls.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77
final class ApiUrls {
88

9+
// 修改密码
10+
static final String API_USER_PASSWORD = "https://home.cnblogs.com/user/ChangPwd";
11+
912
// 更新头像
1013
static final String API_USER_AVATAR = "https://upload.cnblogs.com/avatar/crop";
1114

module-sdk/src/main/java/com/rae/cnblogs/sdk/api/IUserApi.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ Observable<String> updateNickName(@Field("oldDisplayName") String oldName,
147147
Observable<String> updateAccount(@Field("oldLoginName") String oldName,
148148
@Field("newLoginName") String newName);
149149

150+
/**
151+
* 更新密码
152+
*/
153+
@POST(ApiUrls.API_USER_PASSWORD)
154+
@Headers({JsonBody.CONTENT_TYPE, JsonBody.XHR})
155+
@FormUrlEncoded
156+
Observable<String> changePassword(@Field("oldpwd") String oldPwd,
157+
@Field("newpwd") String newPwd);
150158

151159
/**
152160
* 获取账号信息

0 commit comments

Comments
 (0)