Skip to content

Commit 2b7c78b

Browse files
committed
重构项目结构
1 parent b9e1dc8 commit 2b7c78b

File tree

70 files changed

+446
-139
lines changed

Some content is hidden

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

70 files changed

+446
-139
lines changed

README.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,31 @@
3434

3535
### 功能实现原理
3636

37-
[组件跳转](组件跳转.md)
37+
1. [组件跳转](组件跳转.md)
3838

39-
[组件路由懒加载](组件路由懒加载.md)
39+
2. [组件路由懒加载](组件路由懒加载.md)
4040

41-
[注解处理器](注解处理器要点.md)
41+
3. [参数传递与注入](参数传递与注入.md)
4242

43-
[参数传递与注入](参数传递与注入.md)
4443

45-
[跳转拦截器](跳转拦截器.md)
4644

47-
[组件提供外部服务](组件提供外部服务.md)
45+
4. [组件的生命周期分发](组件的生命周期分发.md)
4846

49-
[组件独立运行](组件独立运行.md)
47+
5. [跳转拦截器](跳转拦截器.md)
5048

51-
[组件代码隔离](组件代码隔离.md)
49+
6. [组件提供外部服务](组件提供外部服务.md)
5250

53-
[组件之间公用代码下沉问题解决方案](组件之间公用代码下沉问题解决方案.md)
51+
7. [获取组件Fragment](获取组件Fragment.md)
52+
53+
54+
55+
8. [组件独立运行](组件独立运行.md)
56+
57+
9. [组件代码隔离](组件代码隔离.md)
58+
59+
10. [组件之间公用代码下沉问题解决方案](组件之间公用代码下沉问题解决方案.md)
60+
61+
62+
63+
11. [注解处理器](注解处理器要点.md)
5464

app/build.gradle

+5-17
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ android {
1616
versionName "1.0"
1717

1818
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19-
20-
javaCompileOptions {
21-
annotationProcessorOptions {
22-
arguments = [BROUTER_MODULE_NAME: project.getName()]
23-
}
24-
}
25-
26-
resourcePrefix 'app_'
2719
}
2820

2921
buildTypes {
@@ -53,24 +45,20 @@ dependencies {
5345
implementation 'com.google.android.material:material:1.2.1'
5446

5547
// component
56-
implementation project(':base')
5748
// 使用插件来进行代码隔离
5849
implementation component(project(':wallet'))
5950
implementation component(project(':login'))
6051
implementation component(project(':card'))
61-
62-
// my libs
63-
implementation project(':graph-task')
52+
implementation component(project(':home'))
6453

6554
// component sdk
66-
implementation project(':wallet-sdk')
67-
implementation project(':login-sdk')
68-
implementation project(':card-sdk')
55+
implementation project(':home-sdk')
56+
57+
// my libs
58+
implementation project(':base')
6959

7060
// route
71-
implementation project(path: ':brouter_annotation')
7261
implementation project(path: ':brouter_api')
73-
annotationProcessor project(path: ':brouter_processor')
7462

7563
// test
7664
testImplementation 'junit:junit:4.13.1'

app/src/main/AndroidManifest.xml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.aprz.brouter">
45

56
<application
67
android:name=".App"
78
android:allowBackup="true"
8-
android:icon="@mipmap/app_ic_launcher"
9+
android:icon="@mipmap/ic_launcher"
910
android:label="@string/app_name"
10-
android:roundIcon="@mipmap/app_ic_launcher_round"
11+
android:roundIcon="@mipmap/ic_launcher_round"
1112
android:supportsRtl="true"
12-
android:theme="@style/BaseAppTheme">
13-
<activity android:name=".MainActivity">
13+
android:theme="@style/BaseAppTheme"
14+
tools:ignore="AllowBackup">
15+
<activity android:name=".SplashActivity">
1416
<intent-filter>
1517
<action android:name="android.intent.action.MAIN" />
1618

1719
<category android:name="android.intent.category.LAUNCHER" />
1820
</intent-filter>
1921
</activity>
20-
<activity android:name=".NotFoundActivity" />
2122
</application>
2223

2324
</manifest>

app/src/main/java/com/aprz/brouter/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class App extends Application {
1212
public void onCreate() {
1313
super.onCreate();
1414
BRouter.init(this, false);
15-
ModuleHelper.register("app");
15+
ModuleHelper.register("home");
1616
ModuleHelper.register("wallet");
1717
ModuleHelper.register("login");
1818
ModuleHelper.register("card");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.aprz.brouter;
2+
3+
import android.os.Bundle;
4+
5+
import androidx.annotation.Nullable;
6+
7+
import com.aprz.base.activity.BaseActivity;
8+
import com.aprz.brouter.api.core.BRouter;
9+
import com.aprz.home.sdk.HomeRouteUrl;
10+
11+
public class SplashActivity extends BaseActivity {
12+
13+
@Override
14+
protected void onCreate(@Nullable Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
17+
setContentView(R.layout.activity_splash);
18+
19+
postDelay(() -> {
20+
BRouter.getInstance().path(HomeRouteUrl.Activity.MAIN).navigate(this);
21+
finish();
22+
},
23+
1000L);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="@color/material_blue_700">
7+
8+
<TextView
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:text="@string/welcome_to_brouter"
12+
android:textColor="@color/colorAccent"
13+
android:textSize="24sp"
14+
app:layout_constraintBottom_toBottomOf="parent"
15+
app:layout_constraintLeft_toLeftOf="parent"
16+
app:layout_constraintRight_toRightOf="parent"
17+
app:layout_constraintTop_toTopOf="parent" />
18+
19+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/mipmap-anydpi-v26/app_ic_launcher.xml

-5
This file was deleted.

app/src/main/res/mipmap-anydpi-v26/app_ic_launcher_round.xml

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background" />
4+
<foreground android:drawable="@drawable/ic_launcher_foreground" />
5+
</adaptive-icon>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background" />
4+
<foreground android:drawable="@drawable/ic_launcher_foreground" />
5+
</adaptive-icon>

app/src/main/res/values/strings.xml

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,4 @@
11
<resources>
22
<string name="app_name">BRouter</string>
3-
<string name="app_navigate_to_wallet_component">跳转到钱包组件</string>
4-
<string name="app_navigate_to_wallet_component2">跳转到钱包组件(带上参数)</string>
5-
<string name="app_navigate_to_wallet_component3">跳转到钱包组件(带上参数,自动注入)</string>
6-
<string name="app_features_are_in_development">功能正在开发中,敬请期待…</string>
7-
<string name="app_navigate_login">跳转到登录页面去登录</string>
8-
<string name="app_navigate_wallet_n">跳转到钱包页面,不传递参数,由于该页面有参数检测拦截器,可以点击试试效果(这里是页面拦截器在起作用)</string>
9-
<string name="app_navigate_unknown_url">随便写一个 url,跳转是会发生什么呢?(这里是全局拦截器在起作用)</string>
10-
<string name="app_navigate_wallet_after_login">点击上面的登录按钮,登录成功后,再次尝试登录到钱包页面,这个会传递参数</string>
11-
<string name="app_wallet_crash_degrade">测试钱包页面的降级策略,新的钱包页面有 crash 检测,如果 crash 超过 3 次,则降级到老的钱包页面</string>
12-
<string name="app_test_login_sdk">测试 login 组件对外提供的服务</string>
13-
<string name="app_username_text">用户名:</string>
14-
<string name="app_user_id_text">用户id:</string>
15-
<string name="app_watch_user_info_after_login">去登录,然后回来观察用户信息是否同步了</string>
16-
<string name="app_graph_task_test_case1">用例1</string>
17-
<string name="app_graph_task_test_case2">用例2</string>
18-
<string name="app_graph_task_test_case3">用例3</string>
19-
<string name="app_graph_task_test_case4">用例4</string>
20-
<string name="app_graph_task_test_case5">用例5</string>
21-
<string name="app_graph_task_test_case6">用例6</string>
22-
<string name="app_replace_with_fragment">点击将下方卡片内容替换为其他组件的fragment</string>
3+
<string name="welcome_to_brouter">欢迎来到BRouter</string>
234
</resources>

home-sdk/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

home-sdk/build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
plugins {
2+
id 'com.android.library'
3+
}
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "30.0.2"
8+
9+
defaultConfig {
10+
minSdkVersion 21
11+
targetSdkVersion 30
12+
versionCode 1
13+
versionName "1.0"
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
consumerProguardFiles "consumer-rules.pro"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
33+
implementation 'androidx.appcompat:appcompat:1.2.0'
34+
implementation 'com.google.android.material:material:1.2.1'
35+
testImplementation 'junit:junit:4.13.1'
36+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
37+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
38+
}

home-sdk/consumer-rules.pro

Whitespace-only changes.

home-sdk/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.aprz.home.sdk;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.aprz.home.sdk.test", appContext.getPackageName());
25+
}
26+
}

home-sdk/src/main/AndroidManifest.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.aprz.home.sdk">
4+
5+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.aprz.home.sdk;
2+
3+
public class HomeRouteUrl {
4+
5+
public static final class Activity {
6+
public static final String MAIN = "home/main";
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.aprz.home.sdk;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11+
*/
12+
public class ExampleUnitTest {
13+
@Test
14+
public void addition_isCorrect() {
15+
assertEquals(4, 2 + 2);
16+
}
17+
}

home/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

0 commit comments

Comments
 (0)