Skip to content

Commit 8ee571a

Browse files
committed
接入WorkManager实现版本更新功能
1 parent ba7f09e commit 8ee571a

Some content is hidden

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

55 files changed

+4340
-291
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Jetpack_GitHub
22
[![Platform](https://img.shields.io/badge/platform-Android-green.svg)](https://github.com/fmtjava/OpenGitHub)
3-
[![API](https://img.shields.io/badge/API-17%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=16)
3+
[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=16)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
[![Release Version](https://img.shields.io/badge/version-2.0-red.svg)](https://fir.im/8jw7)
66
[![](https://img.shields.io/badge/Author-fmtjava-blue.svg)](https://github.com/fmtjava)
@@ -84,6 +84,9 @@ Model-View-ViewModel,View 指绿色的 Activity/Fragment,主要负责界面
8484
Glide相比起Fresco要轻量很多,api调用起来也很简洁,对图片加载要求不是很高的话建议使用Glide。
8585

8686
# 更新日志
87+
### v2.1
88+
* 接入WorkManager实现版本更新功能
89+
* 新增smallestWidth限定符屏幕适配方案
8790
### v2.0
8891
* 接入Paging改写动态分页列表页面,并封装Paging版分页模版(BasePagingVMFragment、BaseLPagingModel)
8992
* 提供Paging版分页列表模版以及普通版分页列表模版,方便对比学习

app/build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ kapt {
88
}
99

1010
android {
11-
compileSdkVersion 28
11+
compileSdkVersion 29
1212
defaultConfig {
1313
applicationId "com.fmt.github"
14-
minSdkVersion 17
15-
targetSdkVersion 28
16-
versionCode 9
17-
versionName "2.0"
14+
minSdkVersion 21
15+
targetSdkVersion 29
16+
versionCode 10
17+
versionName "2.1"
1818
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1919
}
2020
signingConfigs {
@@ -33,6 +33,7 @@ android {
3333
signingConfig signingConfigs.release
3434
}
3535
}
36+
3637
dataBinding {
3738
enabled = true
3839
}
@@ -81,6 +82,9 @@ dependencies {
8182
//paging
8283
implementation "androidx.paging:paging-runtime-ktx:2.1.2"
8384

85+
//WorkManager
86+
implementation "androidx.work:work-runtime-ktx:2.3.4"
87+
8488
//koin(依赖注入)
8589
implementation "org.koin:koin-androidx-scope:2.0.1"
8690
implementation "org.koin:koin-androidx-viewmodel:2.0.1"
@@ -93,10 +97,11 @@ dependencies {
9397
implementation 'de.hdodenhof:circleimageview:3.0.0'
9498
implementation 'com.just.agentweb:agentweb:4.0.3-beta'
9599
implementation project(path: ':simplebehavior')
96-
implementation 'com.github.bumptech.glide:glide:4.10.0'
100+
implementation 'com.github.bumptech.glide:glide:4.11.0'
101+
kapt "com.github.bumptech.glide:compiler:4.11.0"
97102
implementation 'com.github.GrenderG:Toasty:1.4.2'
98103
implementation 'com.github.jd-alexander:LikeButton:0.2.3'
99-
implementation 'com.github.Kennyc1012:MultiStateView:2.1'
104+
implementation 'com.github.Kennyc1012:MultiStateView:2.1.2'
100105
implementation 'com.jaredrummler:animated-svg-view:1.0.6'
101106
implementation 'com.jeremyliao:live-event-bus-x:1.4.4'
102107
implementation 'com.github.nitrico.lastadapter:lastadapter:2.3.0'

app/src/main/AndroidManifest.xml

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,74 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:dist="http://schemas.android.com/apk/distribution"
4-
package="com.fmt.github">
3+
xmlns:dist="http://schemas.android.com/apk/distribution"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
package="com.fmt.github">
56

67
<dist:module dist:instant="true" />
78

89
<uses-permission android:name="android.permission.INTERNET" />
910
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1011
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
12+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1113
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
14+
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
1215
<uses-permission android:name="android.permission.READ_LOGS" />
1316

1417
<application
15-
android:name=".App"
16-
android:allowBackup="true"
17-
android:icon="@mipmap/icon_launcher"
18-
android:label="@string/app_name"
19-
android:roundIcon="@mipmap/ic_launcher_round"
20-
android:supportsRtl="true"
21-
android:theme="@style/AppTheme">
22-
<activity android:name=".WelcomeActivity" android:theme="@style/SplashTheme">
18+
android:name=".App"
19+
android:allowBackup="true"
20+
android:icon="@mipmap/icon_launcher"
21+
android:label="@string/app_name"
22+
android:roundIcon="@mipmap/ic_launcher_round"
23+
android:supportsRtl="true"
24+
android:networkSecurityConfig="@xml/network_security_config"
25+
android:theme="@style/AppTheme"
26+
tools:ignore="GoogleAppIndexingWarning">
27+
<activity
28+
android:name=".WelcomeActivity"
29+
android:theme="@style/SplashTheme">
2330
<intent-filter>
2431
<action android:name="android.intent.action.MAIN" />
2532

2633
<category android:name="android.intent.category.LAUNCHER" />
2734
</intent-filter>
2835
</activity>
2936
<activity
30-
android:name=".user.activity.LoginActivity"
31-
android:screenOrientation="portrait" />
37+
android:name=".user.activity.LoginActivity"
38+
android:screenOrientation="portrait" />
3239
<activity
33-
android:name=".home.activity.HomeActivity"
34-
android:screenOrientation="portrait"
35-
android:theme="@style/ToolBarTheme" />
40+
android:name=".home.activity.HomeActivity"
41+
android:screenOrientation="portrait"
42+
android:theme="@style/ToolBarTheme" />
3643

3744
<activity
38-
android:name=".home.activity.CommonSearchActivity"
39-
android:screenOrientation="portrait" />
45+
android:name=".home.activity.CommonSearchActivity"
46+
android:screenOrientation="portrait" />
4047

4148
<activity
42-
android:name=".repos.activity.ReposDetailActivity"
43-
android:screenOrientation="portrait" />
49+
android:name=".repos.activity.ReposDetailActivity"
50+
android:screenOrientation="portrait" />
4451
<activity
45-
android:name=".user.activity.UserInfoActivity"
46-
android:screenOrientation="portrait" />
52+
android:name=".user.activity.UserInfoActivity"
53+
android:screenOrientation="portrait" />
4754
<activity
48-
android:name=".user.activity.AboutActivity"
49-
android:screenOrientation="portrait" />
55+
android:name=".user.activity.AboutActivity"
56+
android:screenOrientation="portrait" />
5057
<activity
51-
android:name=".user.activity.PhotoPreviewActivity"
52-
android:screenOrientation="portrait"
53-
android:theme="@style/FullScreenTheme" />
58+
android:name=".user.activity.PhotoPreviewActivity"
59+
android:screenOrientation="portrait"
60+
android:theme="@style/FullScreenTheme" />
61+
62+
<!-- Android 7.0以上 照片、APK等下载保存路径-->
63+
<provider
64+
android:name="androidx.core.content.FileProvider"
65+
android:authorities="${applicationId}.provider"
66+
android:exported="false"
67+
android:grantUriPermissions="true">
68+
<meta-data
69+
android:name="android.support.FILE_PROVIDER_PATHS"
70+
android:resource="@xml/file_paths" />
71+
</provider>
5472
</application>
5573

5674
</manifest>

app/src/main/java/com/fmt/github/App.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class App : Application() {
1616
super.onCreate()
1717
mApplication = this
1818

19+
//启动器进行异步初始化
1920
TaskDispatcher.init(this)
2021
TaskDispatcher.createInstance()
2122
.addTask(InitBuGlyTask())
@@ -26,4 +27,4 @@ class App : Application() {
2627
}
2728
}
2829

29-
object AppContext : ContextWrapper(mApplication)//ContextWrapper对Context上下文进行包装(装饰者模式)
30+
object AppContext : ContextWrapper(mApplication)//ContextWrapper对Context上下文进行包装(装饰者模式)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.fmt.github
2+
3+
import com.bumptech.glide.annotation.GlideModule
4+
import com.bumptech.glide.module.AppGlideModule
5+
6+
@GlideModule
7+
class GlideModule : AppGlideModule() {
8+
}

app/src/main/java/com/fmt/github/WelcomeActivity.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ class WelcomeActivity : BaseDataBindActivity<ActivityWelcomeBinding>() {
3636
}
3737

3838
private fun askForPermission() {
39-
runWithPermissions(Permission.READ_PHONE_STATE, granted = object : Callback {
40-
override fun invoke(result: AssentResult) {
41-
checkIsLogin()
42-
}
43-
}, denied = object : Callback {
44-
override fun invoke(result: AssentResult) {
45-
finish()
46-
}
47-
})
39+
runWithPermissions(Permission.READ_PHONE_STATE, Permission.READ_EXTERNAL_STORAGE,
40+
Permission.WRITE_EXTERNAL_STORAGE, granted = object : Callback {
41+
override fun invoke(result: AssentResult) {
42+
checkIsLogin()
43+
}
44+
}, denied = object : Callback {
45+
override fun invoke(result: AssentResult) {
46+
finish()
47+
}
48+
})
4849
}
4950

5051
private fun checkIsLogin() {

app/src/main/java/com/fmt/github/config/Configs.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ object Configs {
1616
val SCOPE = listOf("user", "repo", "notifications", "gist")
1717
val FINGERPRINT: String by lazy { Build.FINGERPRINT + UUID.randomUUID().toString() }
1818

19+
//仓库信息
20+
const val OWNER = "fmtjava"
21+
const val OWNER_REPO = "Jetpack_GitHub"
22+
1923
//bugly
2024
const val BUGLY_APP_ID = "8a37e3b7c7"
2125

app/src/main/java/com/fmt/github/constant/Constant.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ object Constant {
77
const val USER_PASSWORD = "password"
88
const val AUTHORIZATIONS = "authorizations"
99
const val AUTHORIZATION = "Authorization"
10-
const val AUTHOR_NAME = "fmtjava"
11-
const val AUTHOR_AVATAR_URL = "https://avatars3.githubusercontent.com/u/16126424?v=4"
10+
const val DOWNLOAD = "download"
1211
const val STAR_EVENT_KEY= "star_event"
1312
}

app/src/main/java/com/fmt/github/data/db/AppDataBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.room.RoomDatabase
55
import com.fmt.github.user.model.db.User
66
import com.fmt.github.user.dao.UserDao
77

8-
@Database(entities = [User::class], version = 1)
8+
@Database(entities = [User::class], version = 1,exportSchema = false)
99
abstract class AppDataBase : RoomDatabase(){
1010

1111
abstract fun getUserDao(): UserDao
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.fmt.github.data.db
2+
3+
import androidx.room.Room
4+
import com.fmt.github.AppContext
5+
6+
private const val DB_NAME = "open_github_db"
7+
8+
val room = Room.databaseBuilder(AppContext, AppDataBase::class.java, DB_NAME).build()
9+
10+
val userDao = room.getUserDao()

0 commit comments

Comments
 (0)