Skip to content

Commit fe7162d

Browse files
committed
集成第三方登录分享并进行抽取隔离,新增界面状态布局(空数据、请求异常、网络异常)、集成 EventBus Apt 插件、新增常用界面模板(个人资料、校验手机、重置手机、查看大图)、新增两个对话框(更新对话框、分享对话框)
1 parent 436af49 commit fe7162d

File tree

239 files changed

+5551
-1154
lines changed

Some content is hidden

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

239 files changed

+5551
-1154
lines changed

AndroidProject.apk

787 KB
Binary file not shown.

ProjectDetails.md

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
* widget:自定义一些精品的 View,不集成任何框架
1212

13-
* umeng:集成友盟 SDK 相关文件,不集成任何框架
14-
1513
> 本项目基于最新的 Android SDK 28 编译,[点击此处查看配置](build.gradle),最低安装要求为 Android 4.0
1614
1715
> 其中 Android Studio 的版本为3.2,Gradle的版本为 4.4

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@
6060

6161
![](picture/25.png)
6262

63+
![](picture/26.png)
64+
65+
![](picture/27.png)
66+
67+
![](picture/28.png)
68+
69+
![](picture/29.png)
70+
71+
![](picture/30.png)
72+
73+
![](picture/31.png)
74+
6375
#### 集成框架
6476

6577
* 权限请求框架:[https://github.com/getActivity/XXPermissions](https://github.com/getActivity/XXPermissions)
@@ -74,6 +86,8 @@
7486

7587
* 圆形ImageView:[https://github.com/hdodenhof/CircleImageView](https://github.com/hdodenhof/CircleImageView)
7688

89+
* 缩放ImageView:[https://github.com/chrisbanes/PhotoView](https://github.com/chrisbanes/PhotoView)
90+
7791
* ButterKnife注解:[https://github.com/JakeWharton/butterknife](https://github.com/JakeWharton/butterknife)
7892

7993
#### 模板项目亮点,[查看详细](ProjectDetails.md)

app/build.gradle

+81-35
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ apply plugin: 'com.android.application'
33
android {
44
compileSdkVersion rootProject.ext.compileSdkVersion
55
buildToolsVersion rootProject.ext.buildToolsVersion
6+
7+
// 使用 JDK 1.8
8+
// compileOptions {
9+
// targetCompatibility JavaVersion.VERSION_1_8
10+
// sourceCompatibility JavaVersion.VERSION_1_8
11+
// }
12+
613
defaultConfig {
714
// 无痛修改包名:https://www.jianshu.com/p/17327e191d2e
815
applicationId "com.hjq.demo"
@@ -11,6 +18,16 @@ android {
1118
versionCode 10
1219
versionName "1.0"
1320
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
21+
22+
// 混淆配置
23+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-app.pro'
24+
25+
javaCompileOptions {
26+
annotationProcessorOptions {
27+
// EventBus Apt 索引类生成位置
28+
arguments = [ eventBusIndex : applicationId + '.MyEventBusIndex' ]
29+
}
30+
}
1431
}
1532

1633
//APK 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2
@@ -39,33 +56,29 @@ android {
3956
zipAlignEnabled true
4057
// 设置混淆
4158
minifyEnabled true
42-
//加载默认混淆配置涵
43-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4459
// 正式环境签名
4560
//signingConfig signingConfigs.release
4661
}
4762

4863
debug {
49-
//ZipAlign优化
64+
// ZipAlign优化
5065
zipAlignEnabled false
51-
//设置混淆
66+
// 设置混淆
5267
minifyEnabled false
53-
//加载默认混淆配置涵
54-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
5568
// 开发环境签名
5669
//signingConfig signingConfigs.debug
5770
}
5871
}
5972

60-
flavorDimensions "default"//这个名字貌似随便取,也可以有多个,总之一定要有
61-
//多渠道打包
73+
flavorDimensions "default" // 这个名字貌似随便取,也可以有多个,总之一定要有
74+
// 友盟多渠道打包
6275
productFlavors {
63-
kuan {} //酷安
64-
tencent {} //应用宝
65-
baidu {} //百度
66-
xiaomi {} //小米
67-
huawei {} //华为
68-
google {} //谷歌
76+
kuan {} // 酷安
77+
tencent {} // 应用宝
78+
baidu {} // 百度
79+
xiaomi {} // 小米
80+
huawei {} // 华为
81+
google {} // 谷歌
6982

7083
productFlavors.all { flavor ->
7184
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
@@ -78,69 +91,102 @@ android {
7891
jniLibs.srcDirs = ['libs']
7992
}
8093
}
94+
95+
// 执行配置
96+
applicationVariants.all { variant ->
97+
98+
// Apk 输出配置
99+
variant.outputs.all { output ->
100+
def appName = "AndroidProject"
101+
if (variant.buildType.name == 'debug') {
102+
outputFileName = appName + '_v' + versionName + '_' + variant.buildType.name + '.apk'
103+
} else {
104+
outputFileName = appName + '_v' + versionName + '_' + new Date().format("yyyyMMdd") + '_' + variant.productFlavors[0].name + '_' + variant.buildType.name + '.apk'
105+
}
106+
}
107+
108+
// AndroidManifest 输出配置
109+
variant.outputs[0].processManifest.doLast {
110+
def manifestFile = "${manifestOutputDirectory}/AndroidManifest.xml"
111+
def updatedContent = new File(manifestFile).getText('UTF-8')
112+
.replaceAll("UMENG_APPKEY_VALUE", "5cb16d93570df399fd0014e2") // 友盟 AppKey
113+
.replaceAll("QQ_APPID_VALUE", "100424468") // QQ AppId
114+
.replaceAll("QQ_APPKEY_VALUE", "c7394704798a158208a74ab60104f0ba") // QQ Key
115+
.replaceAll("WX_APPID_VALUE", "wxdc1e388c3822c80b") // 微信 AppId
116+
.replaceAll("WX_APPKEY_VALUE", "3baf1193c85774b3fd9d18447d76cab0") // 微信 Key
117+
.replaceAll("SN_APPID_VALUE", "3921700954") // 新浪 AppId
118+
.replaceAll("SN_APPKEY_VALUE", "04b48b094faeb16683c32669824ebdad") // 新浪 Key
119+
new File(manifestFile).write(updatedContent, 'UTF-8')
120+
}
121+
}
81122
}
82123

83-
// api 与 implementation的区别:https://www.jianshu.com/p/8962d6ba936e
124+
// api 与 implementation 的区别:https://www.jianshu.com/p/8962d6ba936e
84125
dependencies {
85-
// 依赖 libs 目录下所有 Jar
126+
// 依赖 libs 目录下所有 jar
86127
implementation fileTree(include: ['*.jar'], dir: 'libs')
128+
// 依赖 libs 目录下所有 aar 包
129+
implementation fileTree(include: ['*.aar'], dir: 'libs')
130+
87131
// 基础库(不包任何第三方框架)
88132
implementation project(':base')
89133
// 自定义 View
90134
implementation project(':widget')
91-
// 图片加载封装
135+
// Dialog 封装
136+
implementation project(':dialog')
137+
// Glide 隔离
92138
implementation project(':image')
93-
// 友盟
139+
// 友盟隔离
94140
implementation project(':umeng')
95-
// Dialog
96-
implementation project(':dialog')
97-
98-
// 示例:添加一个 aar 包
99-
// implementation(name: 'library', ext: 'aar')
100141

101142
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
102143
implementation "com.android.support:design:$rootProject.ext.supportLibraryVersion"
103144
implementation "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
104145
implementation "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"
105146
implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"
106147

107-
// Dex分包,解决 65k 问题
148+
// Dex分包,解决 64k 问题
108149
implementation 'com.android.support:multidex:1.0.3'
109150

110-
// ButterKnife注解库:https://github.com/JakeWharton/butterknife
151+
// ButterKnife 注解库:https://github.com/JakeWharton/butterknife
111152
implementation 'com.jakewharton:butterknife:9.0.0-rc1'
112153
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
113154

155+
// EventBus 事件总线
156+
implementation "org.greenrobot:eventbus:3.1.1"
157+
annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.1.1'
158+
114159
// 状态栏沉浸:https://github.com/gyf-dev/ImmersionBar
115160
implementation 'com.gyf.immersionbar:immersionbar:2.3.3'
116161
// 侧滑功能:https://github.com/bingoogolapple/BGASwipeBackLayout-Android
117162
implementation 'cn.bingoogolapple:bga-swipebacklayout:1.2.0'
118163

119164
// 权限请求框架:https://github.com/getActivity/XXPermissions
120-
implementation 'com.hjq:xxpermissions:latest.integration'
165+
implementation 'com.hjq:xxpermissions:5.5'
121166
// 标题栏:https://github.com/getActivity/TitleBar
122-
implementation 'com.hjq:titlebar:latest.integration'
167+
implementation 'com.hjq:titlebar:5.0'
123168
// 吐司工具类:https://github.com/getActivity/ToastUtils
124-
implementation 'com.hjq:toast:latest.integration'
169+
implementation 'com.hjq:toast:6.0'
125170

126171
// 圆形的ImageView:https://github.com/hdodenhof/CircleImageView
127172
implementation 'de.hdodenhof:circleimageview:2.2.0'
128173

174+
// 支持放大缩放的ImageView:https://github.com/chrisbanes/PhotoView
175+
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
176+
177+
// 布局优化:https://github.com/getActivity/Layouts
178+
// 分割线:https://github.com/getActivity/RecyclerItemDecoration
179+
// 国际化:https://github.com/getActivity/MultiLanguages
129180
// 悬浮窗:https://github.com/getActivity/XToast
130181
// 网络请求:https://github.com/zhou-you/RxEasyHttp
131182
// RxJava: https://github.com/ReactiveX/RxAndroid
132183
// RecyclerView:https://github.com/CymChad/BaseRecyclerViewAdapterHelper
184+
// 上拉刷新下拉加载:https://github.com/scwang90/SmartRefreshLayout
133185
// 工具类:https://github.com/Blankj/AndroidUtilCode
134186
// 图片选择:https://github.com/zhihu/Matisse
135-
// 上拉下拉:https://github.com/bingoogolapple/BGARefreshLayout-Android
136187
// 轮播图:https://github.com/bingoogolapple/BGABanner-Android
137188
// 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
138189
// 第三方支付:https://github.com/getActivity/RxPay
139190
// Log 打印:https://github.com/JakeWharton/timber
140-
}
141-
142-
repositories {
143-
flatDir {
144-
dirs 'libs' //就是你放aar的目录地址
145-
}
191+
// 重要数据存储:https://github.com/Tencent/MMKV
146192
}
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,52 @@
1-
# 混淆保护自己项目的部分代码以及引用的第三方jar包
2-
#-libraryjars libs/umeng-analytics-v5.2.4.jar
3-
4-
# 标题栏框架
5-
-keep class com.hjq.bar.** {*;}
6-
7-
# 吐司框架
8-
-keep class com.hjq.toast.** {*;}
9-
10-
# 权限请求框架
11-
-keep class com.hjq.permissions.** {*;}
12-
13-
# 友盟
14-
-keep class com.umeng.**{*;}
15-
16-
# 支付宝
17-
-keep class com.alipay.android.app.IAliPay{*;}
18-
-keep class com.alipay.android.app.IAlixPay{*;}
19-
-keep class com.alipay.android.app.IRemoteServiceCallback{*;}
20-
-keep class com.alipay.android.app.lib.ResourceMap{*;}
21-
22-
#移除log 测试了下没有用还是建议自己定义一个开关控制是否输出日志
23-
#-assumenosideeffects class android.util.Log {
24-
# public static boolean isLoggable(java.lang.String, int);
25-
# public static int v(...);
26-
# public static int i(...);
27-
# public static int w(...);
28-
# public static int d(...);
29-
# public static int e(...);
30-
#}
31-
32-
# webview + js
33-
-keepattributes *JavascriptInterface*
34-
# keep 使用 webview 的类
35-
-keepclassmembers class com.veidy.activity.WebViewActivity {
36-
public *;
37-
}
38-
# keep 使用 webview 的类的所有的内部类
39-
-keepclassmembers class com.veidy.activity.WebViewActivity$*{
40-
*;
41-
}
42-
43-
# 不混淆WebChromeClient中的openFileChooser方法
44-
-keepclassmembers class * extends android.webkit.WebChromeClient{
45-
public void openFileChooser(...);
46-
}
47-
48-
#极光推送
49-
-dontoptimize
50-
-dontpreverify
51-
52-
-dontwarn cn.jpush.**
53-
-keep class cn.jpush.** { *; }
54-
-keep class * extends cn.jpush.android.helpers.JPushMessageReceiver { *; }
55-
56-
-dontwarn cn.jiguang.**
57-
-keep class cn.jiguang.** { *; }
58-
59-
########################################################
60-
61-
# 友盟统计
62-
-keep class com.umeng.** {*;}
63-
-keepclassmembers class * {
64-
public <init> (org.json.JSONObject);
65-
}
66-
-keepclassmembers enum * {
67-
public static **[] values();
68-
public static ** valueOf(java.lang.String);
69-
}
70-
71-
-keep public class [您的应用包名].R$*{
72-
public static final int *;
73-
}
1+
# 忽略警告
2+
#-ignorewarning
3+
4+
# 混淆保护自己项目的部分代码以及引用的第三方jar包
5+
#-libraryjars libs/umeng-analytics-v5.2.4.jar
6+
7+
-keep class com.github.chrisbanes.photoview.** {*;}
8+
9+
# 标题栏框架
10+
-keep class com.hjq.bar.** {*;}
11+
12+
# 吐司框架
13+
-keep class com.hjq.toast.** {*;}
14+
15+
# 权限请求框架
16+
-keep class com.hjq.permissions.** {*;}
17+
18+
#移除log 测试了下没有用还是建议自己定义一个开关控制是否输出日志
19+
#-assumenosideeffects class android.util.Log {
20+
# public static boolean isLoggable(java.lang.String, int);
21+
# public static int v(...);
22+
# public static int i(...);
23+
# public static int w(...);
24+
# public static int d(...);
25+
# public static int e(...);
26+
#}
27+
28+
# webview + js
29+
-keepattributes *JavascriptInterface*
30+
# keep 使用 webview 的类
31+
-keepclassmembers class com.veidy.activity.WebViewActivity {
32+
public *;
33+
}
34+
# keep 使用 webview 的类的所有的内部类
35+
-keepclassmembers class com.veidy.activity.WebViewActivity$*{
36+
*;
37+
}
38+
39+
# 不混淆WebChromeClient中的openFileChooser方法
40+
-keepclassmembers class * extends android.webkit.WebChromeClient{
41+
public void openFileChooser(...);
42+
}
43+
44+
# EventBus3
45+
-keepattributes *Annotation*
46+
-keepclassmembers class ** {
47+
@org.greenrobot.eventbus.Subscribe <methods>;
48+
}
49+
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
50+
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
51+
<init>(java.lang.Throwable);
52+
}

0 commit comments

Comments
 (0)