From 478e9ffd2f0b8a646cc9698116169b5686dff110 Mon Sep 17 00:00:00 2001 From: Quyunshuo Date: Thu, 27 Aug 2020 17:08:52 +0800 Subject: [PATCH] =?UTF-8?q?Modify:=20=E6=B7=BB=E5=8A=A0Common=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=9B=B8=E5=85=B3=E5=85=AC=E5=85=B1=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib_Base/build.gradle | 2 + Lib_Base/src/main/AndroidManifest.xml | 6 +-- Lib_Base/src/main/res/values/colors.xml | 6 +-- Lib_Base/src/main/res/values/styles.xml | 8 +-- Lib_Common/.gitignore | 1 + Lib_Common/build.gradle | 50 +++++++++++++++++++ Lib_Common/consumer-rules.pro | 0 Lib_Common/proguard-rules.pro | 21 ++++++++ .../common/ExampleInstrumentedTest.kt | 24 +++++++++ Lib_Common/src/main/AndroidManifest.xml | 1 + .../com/quyunshuo/common/CommonApplication.kt | 12 +++++ .../com/quyunshuo/common/ExampleUnitTest.kt | 17 +++++++ .../java/com/quyunshuo/main/MainActivity.kt | 9 +++- .../src/main/java/debug/AndroidManifest.xml | 4 +- ...tivity_main.xml => main_activity_main.xml} | 8 +++ README.md | 5 +- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 +- .../androidbaseframemvvm/AppApplication.kt | 6 +-- moduleBase.gradle | 2 +- settings.gradle | 1 + 21 files changed, 161 insertions(+), 26 deletions(-) create mode 100644 Lib_Common/.gitignore create mode 100644 Lib_Common/build.gradle create mode 100644 Lib_Common/consumer-rules.pro create mode 100644 Lib_Common/proguard-rules.pro create mode 100644 Lib_Common/src/androidTest/java/com/quyunshuo/common/ExampleInstrumentedTest.kt create mode 100644 Lib_Common/src/main/AndroidManifest.xml create mode 100644 Lib_Common/src/main/java/com/quyunshuo/common/CommonApplication.kt create mode 100644 Lib_Common/src/test/java/com/quyunshuo/common/ExampleUnitTest.kt rename Lib_Main/src/main/res/layout/{activity_main.xml => main_activity_main.xml} (55%) diff --git a/Lib_Base/build.gradle b/Lib_Base/build.gradle index 7932464..783fb5e 100644 --- a/Lib_Base/build.gradle +++ b/Lib_Base/build.gradle @@ -27,6 +27,8 @@ android { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() } + + resourcePrefix "base_" } kapt { diff --git a/Lib_Base/src/main/AndroidManifest.xml b/Lib_Base/src/main/AndroidManifest.xml index 6baad34..102648e 100644 --- a/Lib_Base/src/main/AndroidManifest.xml +++ b/Lib_Base/src/main/AndroidManifest.xml @@ -1,5 +1 @@ - - - / - \ No newline at end of file + \ No newline at end of file diff --git a/Lib_Base/src/main/res/values/colors.xml b/Lib_Base/src/main/res/values/colors.xml index 4faecfa..b7cee75 100644 --- a/Lib_Base/src/main/res/values/colors.xml +++ b/Lib_Base/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ - #6200EE - #3700B3 - #03DAC5 + #6200EE + #3700B3 + #03DAC5 \ No newline at end of file diff --git a/Lib_Base/src/main/res/values/styles.xml b/Lib_Base/src/main/res/values/styles.xml index 0eb88fe..2e0648e 100644 --- a/Lib_Base/src/main/res/values/styles.xml +++ b/Lib_Base/src/main/res/values/styles.xml @@ -1,11 +1,11 @@ - diff --git a/Lib_Common/.gitignore b/Lib_Common/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/Lib_Common/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Lib_Common/build.gradle b/Lib_Common/build.gradle new file mode 100644 index 0000000..98fda6a --- /dev/null +++ b/Lib_Common/build.gradle @@ -0,0 +1,50 @@ +import com.quyunshuo.androidbaseframemvvm.build.* + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' +apply plugin: 'dagger.hilt.android.plugin' + +android { + compileSdkVersion BuildConfig.compileSdkVersion + buildToolsVersion BuildConfig.buildToolsVersion + + defaultConfig { + minSdkVersion BuildConfig.minSdkVersion + targetSdkVersion BuildConfig.targetSdkVersion + versionCode BuildConfig.versionCode + versionName BuildConfig.versionName + testInstrumentationRunner AndroidX.AndroidJUnitRunner + consumerProguardFiles "consumer-rules.pro" + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + + resourcePrefix "common_" +} + +kapt { + arguments { + arg("AROUTER_MODULE_NAME", project.getName()) + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + + api project(path: ':Lib_Base') + + implementation JetPack.HiltDaggerAndroid + kapt JetPack.HiltDaggerCompiler + kapt JetPack.Hilt + kapt GitHub.GlideCompiler + kapt GitHub.ARouteCompiler +} \ No newline at end of file diff --git a/Lib_Common/consumer-rules.pro b/Lib_Common/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/Lib_Common/proguard-rules.pro b/Lib_Common/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/Lib_Common/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/Lib_Common/src/androidTest/java/com/quyunshuo/common/ExampleInstrumentedTest.kt b/Lib_Common/src/androidTest/java/com/quyunshuo/common/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..bbd6afc --- /dev/null +++ b/Lib_Common/src/androidTest/java/com/quyunshuo/common/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.quyunshuo.common + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.quyunshuo.common.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/Lib_Common/src/main/AndroidManifest.xml b/Lib_Common/src/main/AndroidManifest.xml new file mode 100644 index 0000000..88c64e7 --- /dev/null +++ b/Lib_Common/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Lib_Common/src/main/java/com/quyunshuo/common/CommonApplication.kt b/Lib_Common/src/main/java/com/quyunshuo/common/CommonApplication.kt new file mode 100644 index 0000000..9f76c00 --- /dev/null +++ b/Lib_Common/src/main/java/com/quyunshuo/common/CommonApplication.kt @@ -0,0 +1,12 @@ +package com.quyunshuo.common + +import com.quyunshuo.base.BaseApplication + +/** + * @Author: QuYunShuo + * @Time: 2020/8/27 + * @Class: CommonApplication + * @Remark: 项目相关的Application + */ +open class CommonApplication : BaseApplication() { +} \ No newline at end of file diff --git a/Lib_Common/src/test/java/com/quyunshuo/common/ExampleUnitTest.kt b/Lib_Common/src/test/java/com/quyunshuo/common/ExampleUnitTest.kt new file mode 100644 index 0000000..ad02071 --- /dev/null +++ b/Lib_Common/src/test/java/com/quyunshuo/common/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.quyunshuo.common + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/Lib_Main/src/main/java/com/quyunshuo/main/MainActivity.kt b/Lib_Main/src/main/java/com/quyunshuo/main/MainActivity.kt index 3cc56cc..2724b0e 100644 --- a/Lib_Main/src/main/java/com/quyunshuo/main/MainActivity.kt +++ b/Lib_Main/src/main/java/com/quyunshuo/main/MainActivity.kt @@ -3,10 +3,15 @@ package com.quyunshuo.main import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +/** + * @Author: QuYunShuo + * @Time: 2020/8/27 + * @Class: MainActivity + * @Remark: 主界面Activity + */ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - + setContentView(R.layout.main_activity_main) } } \ No newline at end of file diff --git a/Lib_Main/src/main/java/debug/AndroidManifest.xml b/Lib_Main/src/main/java/debug/AndroidManifest.xml index 8c008d9..2149fe9 100644 --- a/Lib_Main/src/main/java/debug/AndroidManifest.xml +++ b/Lib_Main/src/main/java/debug/AndroidManifest.xml @@ -3,10 +3,10 @@ package="com.quyunshuo.main"> + android:theme="@style/base_AppTheme"> diff --git a/Lib_Main/src/main/res/layout/activity_main.xml b/Lib_Main/src/main/res/layout/main_activity_main.xml similarity index 55% rename from Lib_Main/src/main/res/layout/activity_main.xml rename to Lib_Main/src/main/res/layout/main_activity_main.xml index 0b15a20..ecdf560 100644 --- a/Lib_Main/src/main/res/layout/activity_main.xml +++ b/Lib_Main/src/main/res/layout/main_activity_main.xml @@ -6,4 +6,12 @@ android:layout_height="match_parent" tools:context=".MainActivity"> + \ No newline at end of file diff --git a/README.md b/README.md index 934eab2..d1f13b4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,2 @@ # Android项目框架(组件化 + Kotlin + MVVM + Jetpack ) -note: 1. 组件间资源命名冲突问题 - 2. 组件间不同模式下的清单文件及其他 - 3. 测试打包脚本 - 4. Application \ No newline at end of file +note: 1. 测试打包脚本 \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index de0544a..d0693dd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,6 +72,6 @@ dependencies { if (!BuildConfig.isAppMode) { implementation project(path: ':Lib_Main') } else { - implementation project(path: ':Lib_Base') + implementation project(path: ':Lib_Common') } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e67d0ca..c7fcdc5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,6 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" /> + android:theme="@style/base_AppTheme" /> \ No newline at end of file diff --git a/app/src/main/java/com/quyunshuo/androidbaseframemvvm/AppApplication.kt b/app/src/main/java/com/quyunshuo/androidbaseframemvvm/AppApplication.kt index 0840a34..2a193da 100644 --- a/app/src/main/java/com/quyunshuo/androidbaseframemvvm/AppApplication.kt +++ b/app/src/main/java/com/quyunshuo/androidbaseframemvvm/AppApplication.kt @@ -1,7 +1,7 @@ package com.quyunshuo.androidbaseframemvvm import androidx.multidex.MultiDex -import com.quyunshuo.base.BaseApplication +import com.quyunshuo.common.CommonApplication /** * @Author: QuYunShuo @@ -9,10 +9,10 @@ import com.quyunshuo.base.BaseApplication * @Class: AppApplication * @Remark: 壳App的Application 负责需要写在App包下的初始化逻辑 */ -class AppApplication : BaseApplication() { +class AppApplication : CommonApplication() { override fun onCreate() { - super.onCreate() MultiDex.install(this) + super.onCreate() } } \ No newline at end of file diff --git a/moduleBase.gradle b/moduleBase.gradle index 0476545..3fc1713 100644 --- a/moduleBase.gradle +++ b/moduleBase.gradle @@ -71,7 +71,7 @@ kapt { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - api project(path: ':Lib_Base') + api project(path: ':Lib_Common') testImplementation Android.Junit androidTestImplementation AndroidX.TestExtJunit diff --git a/settings.gradle b/settings.gradle index 9244785..4f800cd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ +include ':Lib_Common' include ':Lib_Main' include ':Lib_Base' include ':app'