Skip to content

Commit fe46695

Browse files
committed
添加字体设置功能
1 parent 883f2f1 commit fe46695

14 files changed

+284
-21
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@
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
<!--主界面-->
3838
<activity
3939
android:name=".activity.MainActivity"
4040
android:screenOrientation="portrait"
4141
android:theme="@style/AppTheme.Dark">
42-
<intent-filter>
42+
<!-- <intent-filter>
4343
<action android:name="android.intent.action.MAIN"/>
4444
4545
<category android:name="android.intent.category.LAUNCHER"/>
46-
</intent-filter>
46+
</intent-filter>-->
4747
</activity>
4848

4949
<activity
@@ -128,6 +128,17 @@
128128
android:label="@string/system_message"
129129
android:screenOrientation="portrait"/>
130130

131+
<activity
132+
android:name=".activity.FontSettingActivity"
133+
android:label="@string/font_setting"
134+
android:screenOrientation="portrait">
135+
<intent-filter>
136+
<action android:name="android.intent.action.MAIN"/>
137+
138+
<category android:name="android.intent.category.LAUNCHER"/>
139+
</intent-filter>
140+
</activity>
141+
131142
<service
132143
android:name=".service.CnblogsService"
133144
android:label="@string/service_name"/>

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.Map;
1313

1414
/**
15-
* APP 统计
15+
* APP 埋点统计
1616
* Created by ChenRui on 2017/2/8 0008 11:44.
1717
*/
1818
public final class AppMobclickAgent {
@@ -35,6 +35,15 @@ public static void onCategoryEvent(Context context, String category) {
3535
MobclickAgent.onEvent(context, "APP_CATEGORY", category);
3636
}
3737

38+
/**
39+
* 搜索统计
40+
*
41+
* @param keyword 关键字
42+
*/
43+
public static void onSearchEvent(Context context, String keyword) {
44+
MobclickAgent.onEvent(context, "APP_SEARCH", keyword);
45+
}
46+
3847
/**
3948
* 广告统计
4049
*/

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public class BloggerActivity extends SwipeBackBaseActivity implements IBloggerPr
8686
@BindView(R.id.view_bg_holder)
8787
View mBloggerBackgroundView;
8888

89+
@BindView(R.id.pb_blogger_follow)
90+
View mFollowProgressBar;
91+
8992
@BindView(R.id.layout_blogger)
9093
BloggerLayout mBloggerLayout;
9194

@@ -190,8 +193,7 @@ public void onLoadBloggerInfo(final FriendsInfoBean userInfo) {
190193
if (!TextUtils.isEmpty(userInfo.getAvatar())) {
191194

192195
// 封面图
193-
String coverUrl = String.format("https://files.cnblogs.com/files/%s/app-cover.bmp", userInfo.getBlogApp());
194-
mBackgroundView.setContentDescription(coverUrl);
196+
final String coverUrl = String.format("https://files.cnblogs.com/files/%s/app-cover.bmp", userInfo.getBlogApp());
195197
GlideApp.with(this)
196198
.load(coverUrl)
197199
.listener(new RequestListener<Drawable>() {
@@ -206,13 +208,13 @@ public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawabl
206208

207209
@Override
208210
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
211+
// 如果有封面图,则设置进去
212+
mBackgroundView.setContentDescription(coverUrl);
209213
return false;
210214
}
211215
})
212216
.placeholder(R.drawable.account_top_bg)
213217
.into(mBackgroundView);
214-
215-
// RaeImageLoader.displayImage(userInfo.getAvatar(), mBackgroundView);
216218
}
217219

218220
mBloggerNameView.setText(userInfo.getDisplayName());
@@ -234,13 +236,19 @@ public void onLoadBloggerInfoFailed(String msg) {
234236

235237
@Override
236238
public void onFollowFailed(String msg) {
237-
AppUI.dismiss();
239+
// AppUI.dismiss();
240+
mFollowProgressBar.setVisibility(ViewPager.GONE);
241+
mFollowView.setVisibility(View.VISIBLE);
238242
AppUI.toast(this, msg);
239243
}
240244

241245
@Override
242246
public void onFollowSuccess() {
243-
AppUI.dismiss();
247+
// AppUI.dismiss();
248+
249+
mFollowProgressBar.setVisibility(ViewPager.GONE);
250+
mFollowView.setVisibility(View.VISIBLE);
251+
244252
mFollowView.setText(mBloggerPresenter.isFollowed() ? R.string.cancel_follow : R.string.following);
245253
setResult(RESULT_OK);
246254

@@ -282,7 +290,9 @@ public void onFollowClick() {
282290
public void onFollowButtonClick() {
283291
if (mUserInfo == null) return;
284292

285-
AppUI.loading(this);
293+
// AppUI.loading(this);
294+
mFollowProgressBar.setVisibility(ViewPager.VISIBLE);
295+
mFollowView.setVisibility(View.GONE);
286296
mBloggerPresenter.doFollow();
287297
}
288298

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.rae.cnblogs.activity;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.util.Log;
6+
import android.widget.SeekBar;
7+
import android.widget.TextView;
8+
9+
import com.rae.cnblogs.R;
10+
11+
import butterknife.BindView;
12+
13+
/**
14+
* 字体设置
15+
* Created by ChenRui on 2017/10/12 0012 23:30.
16+
*/
17+
public class FontSettingActivity extends SwipeBackBaseActivity {
18+
@BindView(R.id.tv_message)
19+
TextView mMessage;
20+
@BindView(R.id.seekBar)
21+
SeekBar mSeekBar;
22+
23+
@Override
24+
protected void onCreate(@Nullable Bundle savedInstanceState) {
25+
super.onCreate(savedInstanceState);
26+
setContentView(R.layout.activity_font_setting);
27+
showHomeAsUp();
28+
29+
30+
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
31+
@Override
32+
public void onProgressChanged(SeekBar seekBar, int value, boolean b) {
33+
switch (value) {
34+
case 0:
35+
mMessage.setTextSize(14);
36+
break;
37+
case 1:
38+
mMessage.setTextSize(16);
39+
break;
40+
case 2:
41+
mMessage.setTextSize(18);
42+
break;
43+
case 3:
44+
mMessage.setTextSize(24);
45+
break;
46+
case 4:
47+
mMessage.setTextSize(26);
48+
break;
49+
}
50+
51+
int width = mSeekBar.getWidth() - mSeekBar.getPaddingLeft() - mSeekBar.getPaddingRight();
52+
int thumbPos = mSeekBar.getPaddingLeft() + width * mSeekBar.getProgress() / mSeekBar.getMax();
53+
54+
Log.i("rae", "大小:" + thumbPos);
55+
}
56+
57+
@Override
58+
public void onStartTrackingTouch(SeekBar seekBar) {
59+
60+
}
61+
62+
@Override
63+
public void onStopTrackingTouch(SeekBar seekBar) {
64+
65+
}
66+
});
67+
}
68+
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,19 @@ public void onResume() {
9898
MobclickAgent.onPageStart("博客列表");
9999
// 统计分类
100100
if (mCategory != null) {
101-
AppMobclickAgent.onCategoryEvent(getContext(), mCategory.getName());
101+
onMobclickAgent(mCategory);
102102
}
103103
}
104104

105+
/**
106+
* 当前友盟统计事件触发
107+
*
108+
* @param category 分类
109+
*/
110+
protected void onMobclickAgent(CategoryBean category) {
111+
AppMobclickAgent.onCategoryEvent(getContext(), category.getName());
112+
}
113+
105114
@Override
106115
public void onDestroy() {
107116
mItemAdapter.destroy();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.os.Bundle;
44
import android.support.annotation.Nullable;
55

6+
import com.rae.cnblogs.AppMobclickAgent;
67
import com.rae.cnblogs.message.SearchEvent;
78
import com.rae.cnblogs.presenter.CnblogsPresenterFactory;
89
import com.rae.cnblogs.presenter.IBlogListPresenter;
@@ -44,6 +45,11 @@ protected void onLoadData() {
4445
mPlaceholderView.dismiss();
4546
}
4647

48+
@Override
49+
protected void onMobclickAgent(CategoryBean category) {
50+
// 搜索统计
51+
AppMobclickAgent.onSearchEvent(getContext(), category.getName());
52+
}
4753

4854
@Subscribe
4955
public void onEvent(SearchEvent event) {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,14 @@ public void onSearchClick() {
240240
private void preformSearch() {
241241
// 弹下键盘
242242
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
243-
imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
244-
// 取消搜索建议
243+
if (imm != null) {
244+
imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
245+
}
246+
247+
// 取消/清除搜索建议数据
245248
mSuggestionAdapter.clear();
246249
mSuggestionAdapter.notifyDataSetChanged();
247-
// 显示或者隐藏
250+
// 显示或者隐藏搜索建议
248251
mRecyclerView.setVisibility(mSearchView.length() > 0 ? View.GONE : View.VISIBLE);
249252

250253
EventBus.getDefault().post(new SearchEvent(getSearchText()));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<stroke
4+
android:width="0.5dp"
5+
android:color="@color/ph1"/>
6+
</shape>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2015 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<selector xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:constantSize="true">
19+
<!-- <item android:state_enabled="false" android:state_pressed="true">
20+
<bitmap android:gravity="center"
21+
android:src="@drawable/abc_scrubber_control_off_mtrl_alpha"/>
22+
</item>
23+
<item android:state_enabled="false">
24+
<bitmap android:gravity="center"
25+
android:src="@drawable/abc_scrubber_control_off_mtrl_alpha"/>
26+
</item>
27+
<item android:state_pressed="true">
28+
<bitmap android:gravity="center"
29+
android:src="@drawable/abc_scrubber_control_to_pressed_mtrl_005"/>
30+
</item>-->
31+
<item>
32+
<shape android:shape="oval">
33+
<solid android:color="@color/badge_color"/>
34+
<size android:width="18dp" android:height="18dp"/>
35+
</shape>
36+
</item>
37+
</selector>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:id="@android:id/background"
5+
android:gravity="center_vertical|fill_horizontal">
6+
<shape
7+
android:shape="rectangle"
8+
android:tint="@color/ph1">
9+
<size android:height="1dp"/>
10+
<solid android:color="@color/ph1"/>
11+
</shape>
12+
</item>
13+
<item
14+
android:id="@android:id/progress"
15+
android:gravity="center_vertical|fill_horizontal">
16+
<scale android:scaleWidth="100%">
17+
<selector>
18+
<item
19+
android:drawable="@android:color/transparent"
20+
android:state_enabled="false"/>
21+
<item>
22+
<shape
23+
android:shape="rectangle"
24+
android:tint="@android:color/transparent">
25+
<size android:height="1dp"/>
26+
<solid android:color="@android:color/transparent"/>
27+
</shape>
28+
</item>
29+
</selector>
30+
</scale>
31+
</item>
32+
</layer-list>

0 commit comments

Comments
 (0)