Skip to content

Commit 8f78eca

Browse files
committed
create(Demo): 创建 DevHttpCaptureUse 使用示例项目
1 parent 484c845 commit 8f78eca

23 files changed

+320
-1
lines changed

application/DevEnvironmentUse/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
android:label="@string/app_name"
99
android:requestLegacyExternalStorage="true"
1010
android:roundIcon="@mipmap/icon_launcher_round"
11-
android:theme="@style/AppTheme">
11+
android:theme="@style/AppTheme.Launcher">
1212

1313
<activity
1414
android:name=".MainActivity"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
tools:ignore="ResourceName">
5+
6+
<item android:id="@android:id/background">
7+
<color android:color="@color/white" />
8+
</item>
9+
10+
<item
11+
android:width="200.0dp"
12+
android:height="200.0dp"
13+
android:drawable="@mipmap/launcher_window_bg"
14+
android:gravity="center" />
15+
</layer-list>
Binary file not shown.

application/DevEnvironmentUse/src/main/res/values/resources.xml

+8
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@
33
<string name="app_name" translatable="false">环境配置示例</string>
44

55
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" />
6+
7+
<style name="AppTheme.Launcher" parent="AppTheme">
8+
<!-- 不设置为全屏防止状态栏隐藏紧接着又显示 -->
9+
<item name="android:windowFullscreen">false</item>
10+
<item name="android:splitMotionEvents">false</item>
11+
<item name="android:windowEnableSplitTouch">false</item>
12+
<item name="android:windowBackground">@drawable/launcher_bg</item>
13+
</style>
614
</resources>
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apply from: rootProject.file(files.build_app_gradle)
2+
3+
android {
4+
namespace "afkt.httpcapture.use"
5+
6+
defaultConfig {
7+
applicationId "afkt.httpcapture.use"
8+
}
9+
}
10+
11+
// Android lib 依赖配置
12+
apply from: rootProject.file(deps_maven.deps_android)
13+
// DevUtils 项目统一依赖配置
14+
apply from: rootProject.file(deps_maven.prop_dev_utils)
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,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="afkt.httpcapture.use">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/icon_launcher"
8+
android:label="@string/app_name"
9+
android:requestLegacyExternalStorage="true"
10+
android:roundIcon="@mipmap/icon_launcher_round"
11+
android:theme="@style/AppTheme.Launcher">
12+
13+
<activity
14+
android:name=".MainActivity"
15+
android:exported="true">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package afkt.httpcapture.use
2+
3+
import afkt.httpcapture.use.base.BaseViewModel
4+
5+
class AppViewModel : BaseViewModel() {
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package afkt.httpcapture.use
2+
3+
import afkt.httpcapture.use.base.BaseActivity
4+
import afkt.httpcapture.use.databinding.ActivityMainBinding
5+
6+
class MainActivity : BaseActivity<ActivityMainBinding, AppViewModel>(
7+
R.layout.activity_main, simple_Agile = {
8+
if (it is MainActivity) {
9+
10+
}
11+
}
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package afkt.httpcapture.use
2+
3+
import afkt.httpcapture.use.base.BaseFragment
4+
import afkt.httpcapture.use.databinding.FragmentMainBinding
5+
6+
class MainFragment : BaseFragment<FragmentMainBinding, AppViewModel>(
7+
R.layout.fragment_main, BR.viewModel, simple_Agile = { it ->
8+
if (it is MainFragment) {
9+
10+
}
11+
}
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package afkt.httpcapture.use.base
2+
3+
import android.os.Bundle
4+
import androidx.activity.enableEdgeToEdge
5+
import androidx.core.view.ViewCompat
6+
import androidx.core.view.WindowInsetsCompat
7+
import androidx.databinding.ViewDataBinding
8+
import dev.simple.app.BaseAppActivity
9+
import dev.simple.app.base.ActivityVMType
10+
import dev.simple.app.base.inter.BindingActivityView
11+
import dev.simple.app.controller.ui.theme.ActivityUITheme
12+
13+
/**
14+
* detail: Activity MVVM 基类
15+
* @author Ttt
16+
*/
17+
open class BaseActivity<VDB : ViewDataBinding, VM : BaseViewModel> :
18+
BaseAppActivity<VDB, VM> {
19+
20+
// ==========
21+
// = 构造函数 =
22+
// ==========
23+
24+
constructor(
25+
bindLayoutId: Int,
26+
bindViewModelId: Int = -1,
27+
vmType: ActivityVMType = ActivityVMType.ACTIVITY,
28+
simple_Init: ((Any) -> Unit)? = null,
29+
simple_Start: ((Any) -> Unit)? = null,
30+
simple_PreLoad: ((Any) -> Unit)? = null,
31+
simple_Agile: ((Any) -> Unit)? = null,
32+
simple_UITheme: ((ActivityUITheme) -> ActivityUITheme)? = null
33+
) : super(
34+
bindLayoutId, bindViewModelId, vmType,
35+
simple_Init, simple_Start, simple_PreLoad, simple_Agile, simple_UITheme
36+
)
37+
38+
constructor(
39+
bindLayoutView: BindingActivityView?,
40+
bindViewModelId: Int = -1,
41+
vmType: ActivityVMType = ActivityVMType.ACTIVITY,
42+
simple_Init: ((Any) -> Unit)? = null,
43+
simple_Start: ((Any) -> Unit)? = null,
44+
simple_PreLoad: ((Any) -> Unit)? = null,
45+
simple_Agile: ((Any) -> Unit)? = null,
46+
simple_UITheme: ((ActivityUITheme) -> ActivityUITheme)? = null
47+
) : super(
48+
bindLayoutView, bindViewModelId, vmType,
49+
simple_Init, simple_Start, simple_PreLoad, simple_Agile, simple_UITheme
50+
)
51+
52+
// ============
53+
// = override =
54+
// ============
55+
56+
override fun onCreate(savedInstanceState: Bundle?) {
57+
super.onCreate(savedInstanceState)
58+
enableEdgeToEdge()
59+
60+
// 给 view 设置 insets, 使得 view 不会被 system bars 遮挡
61+
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
62+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
63+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
64+
insets
65+
}
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package afkt.httpcapture.use.base
2+
3+
import androidx.databinding.ViewDataBinding
4+
import dev.simple.app.BaseAppFragment
5+
import dev.simple.app.base.FragmentVMType
6+
import dev.simple.app.base.inter.BindingFragmentView
7+
import dev.simple.app.controller.ui.theme.FragmentUITheme
8+
9+
/**
10+
* detail: Fragment MVVM 基类
11+
* @author Ttt
12+
*/
13+
open class BaseFragment<VDB : ViewDataBinding, VM : BaseViewModel> :
14+
BaseAppFragment<VDB, VM> {
15+
16+
// ==========
17+
// = 构造函数 =
18+
// ==========
19+
20+
constructor(
21+
bindLayoutId: Int,
22+
bindViewModelId: Int = -1,
23+
vmType: FragmentVMType = FragmentVMType.FRAGMENT,
24+
simple_Init: ((Any) -> Unit)? = null,
25+
simple_Start: ((Any) -> Unit)? = null,
26+
simple_PreLoad: ((Any) -> Unit)? = null,
27+
simple_Agile: ((Any) -> Unit)? = null,
28+
simple_UITheme: ((FragmentUITheme) -> FragmentUITheme)? = null
29+
) : super(
30+
bindLayoutId, bindViewModelId, vmType,
31+
simple_Init, simple_Start, simple_PreLoad, simple_Agile, simple_UITheme
32+
)
33+
34+
constructor(
35+
bindLayoutView: BindingFragmentView,
36+
bindViewModelId: Int = -1,
37+
vmType: FragmentVMType = FragmentVMType.FRAGMENT,
38+
simple_Init: ((Any) -> Unit)? = null,
39+
simple_Start: ((Any) -> Unit)? = null,
40+
simple_PreLoad: ((Any) -> Unit)? = null,
41+
simple_Agile: ((Any) -> Unit)? = null,
42+
simple_UITheme: ((FragmentUITheme) -> FragmentUITheme)? = null
43+
) : super(
44+
bindLayoutView, bindViewModelId, vmType,
45+
simple_Init, simple_Start, simple_PreLoad, simple_Agile, simple_UITheme
46+
)
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package afkt.httpcapture.use.base
2+
3+
import dev.simple.app.BaseAppViewModel
4+
5+
/**
6+
* detail: Base ViewModel
7+
* @author Ttt
8+
*/
9+
open class BaseViewModel : BaseAppViewModel()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
tools:ignore="ResourceName">
5+
6+
<item android:id="@android:id/background">
7+
<color android:color="@color/white" />
8+
</item>
9+
10+
<item
11+
android:width="200.0dp"
12+
android:height="200.0dp"
13+
android:drawable="@mipmap/launcher_window_bg"
14+
android:gravity="center" />
15+
</layer-list>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
5+
<FrameLayout
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent">
8+
9+
<androidx.fragment.app.FragmentContainerView
10+
android:id="@+id/nav_container"
11+
android:name="androidx.navigation.fragment.NavHostFragment"
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent"
14+
app:defaultNavHost="true"
15+
app:navGraph="@navigation/app_navigation" />
16+
</FrameLayout>
17+
</layout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layout xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<data>
5+
6+
<variable
7+
name="viewModel"
8+
type="afkt.httpcapture.use.AppViewModel" />
9+
</data>
10+
11+
<androidx.core.widget.NestedScrollView
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent"
14+
android:background="@color/black"
15+
android:fadingEdge="none"
16+
android:fitsSystemWindows="true"
17+
android:overScrollMode="never"
18+
android:scrollbars="none">
19+
20+
<LinearLayout
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:orientation="vertical"></LinearLayout>
24+
</androidx.core.widget.NestedScrollView>
25+
</layout>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
app:startDestination="@id/MainFragment">
5+
6+
<fragment
7+
android:id="@+id/MainFragment"
8+
android:name="afkt.httpcapture.use.MainFragment"
9+
android:label="MainFragment" />
10+
</navigation>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name" translatable="false">抓包示例</string>
4+
5+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" />
6+
7+
<style name="AppTheme.Launcher" parent="AppTheme">
8+
<!-- 不设置为全屏防止状态栏隐藏紧接着又显示 -->
9+
<item name="android:windowFullscreen">false</item>
10+
<item name="android:splitMotionEvents">false</item>
11+
<item name="android:windowEnableSplitTouch">false</item>
12+
<item name="android:windowBackground">@drawable/launcher_bg</item>
13+
</style>
14+
</resources>

settings.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def applications = [
7676

7777
// DevEnvironment - Android 环境配置切换库【使用示例】
7878
"DevEnvironmentUse",
79+
80+
// DevHttpCapture - OkHttp 抓包工具库【使用示例】
81+
"DevHttpCaptureUse",
7982
]
8083

8184
applications.forEach {

0 commit comments

Comments
 (0)