Skip to content

Commit 46adf6b

Browse files
author
ChenRui
committed
修复登录问题:系统检测到异常,暂不允许登录
UI调整
1 parent 6c309a4 commit 46adf6b

Some content is hidden

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

54 files changed

+392
-270
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
android:name=".activity.LauncherActivity"
2828
android:screenOrientation="portrait"
2929
android:theme="@style/AppTheme.NoActionBar.FullScreen">
30-
<!-- <intent-filter>
31-
<action android:name="android.intent.action.MAIN"/>
30+
<intent-filter>
31+
<action android:name="android.intent.action.MAIN"/>
3232

33-
<category android:name="android.intent.category.LAUNCHER"/>
34-
</intent-filter>-->
33+
<category android:name="android.intent.category.LAUNCHER"/>
34+
</intent-filter>
3535
</activity>
3636

3737
<!--主界面-->
@@ -61,12 +61,7 @@
6161
android:name=".activity.LoginActivity"
6262
android:launchMode="singleTop"
6363
android:screenOrientation="portrait"
64-
android:windowSoftInputMode="stateVisible">
65-
<intent-filter>
66-
<action android:name="android.intent.action.MAIN"/>
67-
<category android:name="android.intent.category.LAUNCHER"/>
68-
</intent-filter>
69-
</activity>
64+
android:windowSoftInputMode="stateVisible"/>
7065

7166

7267
<!--网页登录-->

app/src/main/assets/css/rae.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
#header{
66
padding-bottom:20px;
77
}
8+
#blog_title{
9+
text-align: center;
10+
margin-top: 60px;
11+
font-weight: bold;
12+
line-height: 32px;
13+
margin-left: 24px;
14+
margin-right: 24px;
15+
}
16+
#blog_date{
17+
text-align: center;
18+
margin-top: 15px;
19+
display: block;
20+
color: #929292;
21+
}
822
#blog_content{
923
line-height:26px;
1024
}

app/src/main/assets/view.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
<body>
135135
<div class="container-fluid">
136136
<div id="header">
137-
<h3 id="blog_title"></h3>
138-
<span id="blog_date"></span>
137+
<h3 id="blog_title">接口缺失正文内容,可能由于博客发布时间已经久远,接口任性就是没有返回数据</h3>
138+
<span id="blog_date">111111</span>
139139
<!--<a href="javascript:window.locatrefreshCategoryload()">刷新页面</a>-->
140140
</div>
141141
<div id="blog_content">

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ private static void onAdEvent(Context context, Map<String, String> map) {
5050
public static void onLaunchAdExposureEvent(Context context, String id, String name) {
5151
Map<String, String> map = new HashMap<>();
5252
map.put("type", "Exposure");
53-
map.put("ad", id);
54-
map.put("title", name);
53+
map.put("ad", withString(id, "广告ID为空"));
54+
map.put("title", withString(name, "广告标题为空"));
5555
onAdEvent(context, map);
5656
}
5757

@@ -63,8 +63,8 @@ public static void onLaunchAdExposureEvent(Context context, String id, String na
6363
public static void onLaunchAdClickEvent(Context context, String id, String name) {
6464
Map<String, String> map = new HashMap<>();
6565
map.put("type", "Click");
66-
map.put("id", id);
67-
map.put("name", name);
66+
map.put("id", withString(id, "广告ID为空"));
67+
map.put("name", withString(name, "广告标题为空"));
6868
onAdEvent(context, map);
6969
}
7070

@@ -98,4 +98,14 @@ public static void onClickEvent(Context context, String name) {
9898
MobclickAgent.onEvent(context, "APP_CLICK_EVENT", name);
9999
}
100100

101+
/**
102+
* 使用默认值的字符串
103+
*
104+
* @param text 源
105+
* @param defValue 默认值
106+
*/
107+
private static String withString(String text, String defValue) {
108+
return TextUtils.isEmpty(text) ? defValue : text;
109+
}
110+
101111
}

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.ContextWrapper;
66
import android.support.annotation.NonNull;
77
import android.support.v4.content.ContextCompat;
8+
import android.util.TypedValue;
89
import android.view.Gravity;
910
import android.widget.TextView;
1011
import android.widget.Toast;
@@ -24,9 +25,6 @@ public final class AppUI {
2425

2526
private static WeakReference<IAppDialog> dialogWeakReference;
2627

27-
public static Toast failed(Context context, String msg) {
28-
return toastInCenter(context, msg);
29-
}
3028

3129
public static Toast toast(Context context, String msg) {
3230
Toast toast = makeToast(context, msg);
@@ -50,9 +48,13 @@ private static Toast makeToast(Context context, String msg) {
5048
return toast;
5149
}
5250
toast.getView().setBackgroundDrawable(context.getResources().getDrawable(R.drawable.bg_toast));
53-
TextView msgView = (TextView) toast.getView().findViewById(android.R.id.message);
54-
msgView.setTextSize(14);
55-
msgView.setTextColor(ContextCompat.getColor(context, android.R.color.white));
51+
TextView msgView = toast.getView().findViewById(android.R.id.message);
52+
if (msgView != null) {
53+
int p = 12;
54+
msgView.setPadding(p, p, p, p);
55+
msgView.setTextSize(14);
56+
msgView.setTextColor(ContextCompat.getColor(context, R.color.white));
57+
}
5658
return toast;
5759
}
5860

@@ -90,7 +92,30 @@ public static IAppDialog loading(Context context, int resId) {
9092
}
9193

9294
public static void success(Context context, int resId) {
93-
toast(context, context.getString(resId));
95+
Toast toast = makeToast(context, context.getString(resId));
96+
toast.setGravity(Gravity.CENTER, 0, 0);
97+
TextView msgView = toast.getView().findViewById(android.R.id.message);
98+
if (msgView != null) {
99+
int p = 20;
100+
msgView.setPadding(p, p, p, p);
101+
msgView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.toast_success, 0, 0);
102+
msgView.setCompoundDrawablePadding((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()));
103+
}
104+
toast.show();
105+
}
106+
107+
public static Toast failed(Context context, String msg) {
108+
Toast toast = makeToast(context, msg);
109+
toast.setGravity(Gravity.CENTER, 0, 0);
110+
TextView msgView = toast.getView().findViewById(android.R.id.message);
111+
if (msgView != null) {
112+
int p = 20;
113+
msgView.setPadding(p, p, p, p);
114+
msgView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.toast_failed, 0, 0);
115+
msgView.setCompoundDrawablePadding((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()));
116+
}
117+
toast.show();
118+
return toast;
94119
}
95120

96121
public static void dismiss() {
@@ -107,5 +132,4 @@ public static void dismiss() {
107132
}
108133

109134

110-
111135
}

app/src/main/java/com/rae/cnblogs/activity/LoginActivity.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ public void afterTextChanged(Editable editable) {
126126
@Override
127127
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
128128
if (isChecked) {
129-
//选择状态 显示明文--设置为可见的密码
129+
// 选择状态 显示明文--设置为可见的密码
130130
mPasswordView.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
131131
} else {
132-
//默认状态显示密码--设置文本 要一起写才能起作用 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD
132+
// 默认状态显示密码--设置文本 要一起写才能起作用 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD
133133
mPasswordView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
134134
}
135135

@@ -142,8 +142,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
142142
mLoginContractDialog.setMessage(getString(R.string.login_contract_content));
143143
mLoginContractDialog.setEnSureText(getString(R.string.agree));
144144

145-
mUserNameView.setText("abc");
146-
mPasswordView.setText("123456");
147145
}
148146

149147
private void addAccountTextListener(AccountTextWatcher watcher) {
@@ -238,6 +236,7 @@ public String getPassword() {
238236

239237
@Override
240238
public void onLoginSuccess(UserInfoBean userInfo) {
239+
AppUI.success(this, R.string.login_success);
241240
onLoginCallback();
242241
setResult(RESULT_OK);
243242
finish();

app/src/main/java/com/rae/cnblogs/activity/WebActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void setTitle(CharSequence title) {
100100

101101
@Override
102102
protected int getHomeAsUpIndicator() {
103-
return R.drawable.ic_search_del;
103+
return R.drawable.ic_back_closed;
104104
}
105105

106106
@OnClick(R.id.img_action_bar_more)

app/src/main/java/com/rae/cnblogs/dialog/impl/ShareDialog.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import android.support.annotation.NonNull;
1010
import android.support.annotation.Nullable;
1111
import android.text.TextUtils;
12+
import android.view.Gravity;
1213
import android.view.View;
14+
import android.view.WindowManager;
1315
import android.view.animation.AlphaAnimation;
1416
import android.view.animation.Animation;
1517
import android.view.animation.AnimationSet;
@@ -210,6 +212,17 @@ private void startAnimSet(List<View> views) {
210212
@Override
211213
public void show() {
212214
super.show();
215+
if (getWindow() != null) {
216+
WindowManager.LayoutParams attr = getWindow().getAttributes();
217+
attr.gravity = Gravity.START | Gravity.END | Gravity.BOTTOM;
218+
attr.horizontalMargin = 0;
219+
attr.verticalMargin = 0;
220+
attr.width = WindowManager.LayoutParams.MATCH_PARENT;
221+
attr.height = WindowManager.LayoutParams.WRAP_CONTENT;
222+
onWindowLayout(getWindow(), attr);
223+
getWindow().setAttributes(attr);
224+
}
225+
213226
showNightText();
214227
startAnim();
215228
}

app/src/main/java/com/rae/cnblogs/fragment/WebLoginFragment.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ public void onDestroy() {
8585
super.onDestroy();
8686
}
8787

88-
private void perfromLogin() {
88+
private void performLogin() {
8989
// 同步COOKIE
90-
UserProvider.getInstance().syncFormWebview();
91-
90+
UserProvider.getInstance().cookieManager2CookieJar();
9291
// 获取用户信息
9392
loadUserInfo();
9493
}
@@ -164,7 +163,7 @@ public void onPageFinished(WebView view, String url) {
164163

165164
// 登录成功
166165
if (cookie != null && cookie.contains(".CNBlogsCookie")) {
167-
perfromLogin();
166+
performLogin();
168167
}
169168
}
170169

app/src/main/java/com/rae/cnblogs/presenter/impl/LoginPresenterImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ public void login() {
5959
.flatMap(new Function<LoginToken, ObservableSource<Empty>>() {
6060
@Override
6161
public ObservableSource<Empty> apply(LoginToken loginToken) throws Exception {
62-
return createObservable(mUserApi.login(loginToken.getVerificationToken(), ApiEncrypt.encrypt(userName), ApiEncrypt.encrypt(pwd)));
62+
return createObservable(
63+
mUserApi.login(
64+
loginToken.getVerificationToken(),
65+
ApiEncrypt.encrypt(userName),
66+
ApiEncrypt.encrypt(pwd),
67+
true));
6368
}
6469
})
6570
.flatMap(new Function<Empty, ObservableSource<UserInfoBean>>() {
@@ -134,7 +139,7 @@ protected void accept(UserInfoBean data) {
134139
}
135140

136141
// [重要] 同步Cookie登录信息
137-
UserProvider.getInstance().syncFormCookieJar();
142+
UserProvider.getInstance().cookieJar2CookieManager();
138143

139144
mView.onLoginSuccess(data);
140145
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-221 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-566 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-341 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Binary file not shown.
Binary file not shown.
Loading

app/src/main/res/drawable/bg_btn_follow.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<item android:state_pressed="true">
55
<shape>
66
<solid android:color="#19FFFFFF"/>
7-
<stroke android:width="0.5dp" android:color="@color/white"/>
7+
<stroke android:width="1dp" android:color="@color/white"/>
88
<corners android:radius="2dp"/>
99
</shape>
1010
</item>
1111
<item>
1212
<shape>
1313
<solid android:color="@android:color/transparent"/>
14-
<stroke android:width="0.5dp" android:color="@color/white"/>
14+
<stroke android:width="1dp" android:color="@color/white"/>
1515
<corners android:radius="2dp"/>
1616
</shape>
1717
</item>

app/src/main/res/drawable/bg_btn_follow_drak.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<item android:state_pressed="true">
55
<shape>
66
<solid android:color="#19FFFFFF"/>
7-
<stroke android:width="0.5dp" android:color="@color/ph2"/>
7+
<stroke android:width="1dp" android:color="@color/ph2"/>
88
<corners android:radius="2dp"/>
99
</shape>
1010
</item>
1111
<item>
1212
<shape>
1313
<solid android:color="@android:color/transparent"/>
14-
<stroke android:width="0.5dp" android:color="@color/ph2"/>
14+
<stroke android:width="1dp" android:color="@color/ph2"/>
1515
<corners android:radius="2dp"/>
1616
</shape>
1717
</item>

app/src/main/res/drawable/ic_like_content.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)