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

Commit b7552f6

Browse files
committed
优化图片大小
1 parent ad35e8d commit b7552f6

File tree

8 files changed

+200
-26
lines changed

8 files changed

+200
-26
lines changed

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ android {
4242
// signingConfig signingConfigs.release
4343
}
4444
release {
45-
minifyEnabled false
45+
//混淆
46+
// minifyEnabled false
47+
// 移除无用的resource文件
48+
// shrinkResources true
4649
signingConfig signingConfigs.release
4750
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4851
}

app/proguard-rules.pro

Lines changed: 192 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,192 @@
1-
# Add project specific ProGuard rules here.
2-
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.
4-
#
5-
# For more details, see
6-
# http://developer.android.com/guide/developing/tools/proguard.html
7-
8-
# If your project uses WebView with JS, uncomment the following
9-
# and specify the fully qualified class name to the JavaScript interface
10-
# class:
11-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12-
# public *;
13-
#}
14-
15-
# Uncomment this to preserve the line number information for
16-
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
18-
19-
# If you keep the line number information, uncomment this to
20-
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
1+
#-------------------------------------------基本不用动区域--------------------------------------------
2+
#---------------------------------基本指令区----------------------------------
3+
-optimizationpasses 5 # 指定代码的压缩级别
4+
-dontusemixedcaseclassnames # 是否使用大小写混合
5+
-dontskipnonpubliclibraryclasses # 指定不去忽略非公共的库类
6+
-dontskipnonpubliclibraryclassmembers # 指定不去忽略包可见的库类的成员
7+
-dontpreverify # 混淆时是否做预校验
8+
-verbose # 混淆时是否记录日志
9+
-printmapping proguardMapping.txt
10+
-optimizations !code/simplification/cast,!field/*,!class/merging/* # 混淆时所采用的算法
11+
-keepattributes *Annotation*,InnerClasses
12+
-keepattributes Signature
13+
-keepattributes SourceFile,LineNumberTable
14+
#----------------------------------------------------------------------------
15+
-ignorewarnings # 是否忽略检测,(是)
16+
#---------------------------------默认保留区---------------------------------
17+
-keep public class * extends android.app.Activity
18+
-keep public class * extends android.app.Application
19+
-keep public class * extends android.app.Service
20+
-keep public class * extends android.content.BroadcastReceiver
21+
-keep public class * extends android.content.ContentProvider
22+
-keep public class * extends android.app.backup.BackupAgentHelper
23+
-keep public class * extends android.preference.Preference
24+
-keep public class * extends android.view.View
25+
-keep public class com.android.vending.licensing.ILicensingService
26+
-keep class android.support.** {*;}
27+
#-ignorewarnings -keep class * { public private *; }
28+
29+
#如果有引用v4包可以添加下面这行
30+
-keep class android.support.v4.** { *; }
31+
-keep public class * extends android.support.v4.**
32+
-keep public class * extends android.app.Fragment
33+
34+
-keepclasseswithmembernames class * {
35+
native <methods>;
36+
}
37+
-keepclassmembers class * extends android.app.Activity{
38+
public void *(android.view.View);
39+
}
40+
-keepclassmembers enum * {
41+
public static **[] values();
42+
public static ** valueOf(java.lang.String);
43+
}
44+
-keep public class * extends android.view.View{
45+
*** get*();
46+
void set*(***);
47+
public <init>(android.content.Context);
48+
public <init>(android.content.Context, android.util.AttributeSet);
49+
public <init>(android.content.Context, android.util.AttributeSet, int);
50+
}
51+
-keepclasseswithmembers class * {
52+
public <init>(android.content.Context, android.util.AttributeSet);
53+
public <init>(android.content.Context, android.util.AttributeSet, int);
54+
}
55+
-keep class * implements android.os.Parcelable {
56+
public static final android.os.Parcelable$Creator *;
57+
}
58+
-keepclassmembers class * implements java.io.Serializable {
59+
static final long serialVersionUID;
60+
private static final java.io.ObjectStreamField[] serialPersistentFields;
61+
private void writeObject(java.io.ObjectOutputStream);
62+
private void readObject(java.io.ObjectInputStream);
63+
java.lang.Object writeReplace();
64+
java.lang.Object readResolve();
65+
}
66+
#表示不混淆R文件中的所有静态字段
67+
-keep class **.R$* {
68+
public static <fields>;
69+
}
70+
-keepclassmembers class * {
71+
void *(**On*Event);
72+
}
73+
#----------------------------------------------------------------------------
74+
75+
#---------------------------------webview------------------------------------
76+
-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
77+
public *;
78+
}
79+
-keepclassmembers class * extends android.webkit.WebViewClient {
80+
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
81+
public boolean *(android.webkit.WebView, java.lang.String);
82+
}
83+
-keepclassmembers class * extends android.webkit.WebViewClient {
84+
public void *(android.webkit.WebView, jav.lang.String);
85+
}
86+
87+
88+
#---------------------------------2.第三方库---------------------------------
89+
#okhttp3
90+
-dontwarn com.squareup.okhttp3.**
91+
-keep class com.squareup.okhttp3.** { *;}
92+
-keep class okhttp3.** { *;}
93+
-keep class okio.** { *;}
94+
-dontwarn sun.security.**
95+
-keep class sun.security.** { *;}
96+
-dontwarn okio.**
97+
-dontwarn okhttp3.**
98+
99+
#retrofit2
100+
-dontwarn retrofit2.**
101+
-keep class retrofit2.** { *; }
102+
-keepattributes Signature
103+
-keepattributes Exceptions
104+
-dontwarn org.robovm.**
105+
-keep class org.robovm.** { *; }
106+
107+
# RxJava RxAndroid
108+
-dontwarn sun.misc.**
109+
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
110+
long producerIndex;
111+
long consumerIndex;
112+
}
113+
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
114+
rx.internal.util.atomic.LinkedQueueNode producerNode;
115+
}
116+
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
117+
rx.internal.util.atomic.LinkedQueueNode consumerNode;
118+
}
119+
-dontnote rx.internal.util.PlatformDependent
120+
121+
# Retrofit, OkHttp, Gson
122+
-keep class com.squareup.okhttp.** { *; }
123+
-keep interface com.squareup.okhttp.** { *; }
124+
-dontwarn com.squareup.okhttp.**
125+
-dontwarn rx.**
126+
-dontwarn retrofit.**
127+
-keep class retrofit.** { *; }
128+
-keepclasseswithmembers class * {
129+
@retrofit.http.* <methods>;
130+
}
131+
-keep class sun.misc.Unsafe { *; }
132+
-dontwarn java.nio.file.*
133+
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
134+
135+
# Rxjava-promises
136+
-keep class com.darylteo.rx.** { *; }
137+
-dontwarn com.darylteo.rx.**
138+
139+
# RxJava 0.21
140+
-keep class rx.schedulers.Schedulers {
141+
public static <methods>;
142+
}
143+
-keep class rx.schedulers.ImmediateScheduler {
144+
public <methods>;
145+
}
146+
-keep class rx.schedulers.TestScheduler {
147+
public <methods>;
148+
}
149+
-keep class rx.schedulers.Schedulers {
150+
public static ** test();
151+
}
152+
153+
#butterknife
154+
-keep class butterknife.** { *; }
155+
-dontwarn butterknife.internal.**
156+
-keep class **$$ViewBinder { *; }
157+
-keepclasseswithmembernames class * {
158+
@butterknife.* <fields>;
159+
}
160+
-keepclasseswithmembernames class * {
161+
@butterknife.* <methods>;
162+
}
163+
164+
# RxLifeCycle2
165+
-keep class com.trello.rxlifecycle2.** { *; }
166+
-keep interface com.trello.rxlifecycle2.** { *; }
167+
-dontwarn com.trello.rxlifecycle2.**
168+
169+
-keep class com.github.mikephil.charting.** { *; }
170+
-dontwarn com.github.mikephil.charting.data.realm.**
171+
172+
173+
#Glide
174+
-keep public class * implements com.bumptech.glide.module.GlideModule
175+
-keep public class * extends com.bumptech.glide.module.AppGlideModule
176+
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
177+
**[] $VALUES;
178+
public *;
179+
}
180+
# for DexGuard only
181+
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
182+
183+
#ARouter
184+
-keep public class com.alibaba.android.arouter.routes.**{*;}
185+
-keep public class com.alibaba.android.arouter.facade.**{*;}
186+
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
187+
# If you use the byType method to obtain Service, add the following rules to protect the interface:
188+
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
189+
# If single-type injection is used, that is, no interface is defined to implement IProvider, the following rules need to be added to protect the implementation
190+
#-keep class * implements com.alibaba.android.arouter.facade.template.IProvider
191+
192+
Binary file not shown.

module-resource/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
<string name="praises">给个好评</string>
9999
<string name="praises_error">您似乎没有安装应用市场</string>
100100
<string name="share_app_url">http://www.raeblog.com/cnblogs/app/share</string>
101-
<string name="share_app_title">分享「博客园」Android客户端</string>
102-
<string name="share_app_desc">博客园,一个面向开发者的知识分享社区,一个纯净的技术交流社区。</string>
101+
<string name="share_app_title">博客园Android客户端</string>
102+
<string name="share_app_desc">一个面向开发者的知识分享社区,一个纯净的技术交流社区。UI风格简洁,给你极致流畅的体验。</string>
103103
<string name="market_url">market://details?id=com.rae.cnblogs</string>
104104
<string name="service_name">博客园服务</string>
105105
<string name="permission_tips_message">博客园需要读取/写入您的存储卡,禁止后大部分功能将受到限制,是否再次申请?</string>

module-user/src/main/java/com/rae/cnblogs/user/fragment/WebLoginFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
6969
mPlaceholderView = new LoginPlaceholderView(view.getContext());
7070
mPlaceholderView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
7171
mPlaceholderView.dismiss();
72-
mPlaceholderView.setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.background_divider));
72+
7373
// 重试按钮
7474
mPlaceholderView.setOnRetryClickListener(new View.OnClickListener() {
7575
@Override
@@ -115,7 +115,7 @@ public void onPageFinished(WebView view, String url) {
115115
String cookie = CookieManager.getInstance().getCookie(url);
116116
// 登录成功
117117
if (cookie != null && cookie.contains(".CNBlogsCookie")) {
118-
// 请求用户信息 每一步的改变都不平凡
118+
// 请求用户信息
119119
// mPlaceholderView.loadingWithTimer(getString(R.string.loading_blog_app));
120120
mPlaceholderView.loadingWithTimer("每一步的改变都不平凡");
121121
mPresenter.loadUserInfo();

0 commit comments

Comments
 (0)