File tree Expand file tree Collapse file tree 6 files changed +77
-5
lines changed
kotlin/com/xiaocydx/inputview/sample Expand file tree Collapse file tree 6 files changed +77
-5
lines changed Original file line number Diff line number Diff line change @@ -35,16 +35,17 @@ android {
3535}
3636
3737dependencies {
38+ implementation(project(" :inputview" ))
39+ implementation(project(" :inputview-compat" ))
40+ val version = " 1.1.2"
41+ implementation(" com.github.xiaocydx.Insets:insets:${version} " )
42+ implementation(" com.github.xiaocydx.Insets:insets-compat:${version} " )
43+ implementation(" com.github.xiaocydx.Insets:insets-systembar:${version} " )
3844 implementation(" androidx.core:core-ktx:1.7.0" )
3945 implementation(" androidx.appcompat:appcompat:1.6.1" )
4046 implementation(" com.google.android.material:material:1.7.0" )
4147 implementation(" androidx.constraintlayout:constraintlayout:2.1.4" )
4248 implementation(" androidx.recyclerview:recyclerview:1.2.0" )
4349 implementation(" androidx.fragment:fragment:1.6.1" )
4450 implementation(" androidx.fragment:fragment-ktx:1.6.1" )
45- implementation(project(" :inputview" ))
46- implementation(project(" :inputview-reflect" ))
47- testImplementation(" junit:junit:4.13.2" )
48- androidTestImplementation(" androidx.test.ext:junit:1.1.5" )
49- androidTestImplementation(" androidx.test.espresso:espresso-core:3.5.1" )
5051}
Original file line number Diff line number Diff line change 33 xmlns : tools =" http://schemas.android.com/tools" >
44
55 <application
6+ android : name =" .App"
67 android : allowBackup =" true"
78 android : dataExtractionRules =" @xml/data_extraction_rules"
89 android : fullBackupContent =" @xml/backup_rules"
3738 <activity
3839 android : name =" .MessageListActivity"
3940 android : screenOrientation =" portrait" />
41+ <activity
42+ android : name =" .InitCompatActivity"
43+ android : screenOrientation =" portrait" />
4044 <activity
4145 android : name =" .fragment.FragmentEditorAdapterActivity"
4246 android : screenOrientation =" portrait" />
Original file line number Diff line number Diff line change 1+ package com.xiaocydx.inputview.sample
2+
3+ import android.app.Application
4+ import com.xiaocydx.insets.systembar.SystemBar
5+ import com.xiaocydx.insets.systembar.install
6+
7+ /* *
8+ * @author xcc
9+ * @date 2023/12/31
10+ */
11+ class App : Application () {
12+
13+ override fun onCreate () {
14+ super .onCreate()
15+ SystemBar .install(this )
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ package com.xiaocydx.inputview.sample
2+
3+ import android.os.Bundle
4+ import android.view.WindowInsets
5+ import androidx.appcompat.app.AppCompatActivity
6+ import com.xiaocydx.inputview.InputView
7+ import com.xiaocydx.inputview.initCompat
8+ import com.xiaocydx.inputview.sample.databinding.MessageListBinding
9+ import com.xiaocydx.inputview.sample.message.init
10+ import com.xiaocydx.insets.systembar.EdgeToEdge
11+ import com.xiaocydx.insets.systembar.SystemBar
12+
13+ /* *
14+ * `InputView.initCompat()`的示例代码
15+ *
16+ * [SystemBar]是一套单Activity多Fragment的SystemBar控制方案,
17+ * [SystemBar]的注入逻辑初始化了window,完成[WindowInsets]的处理,
18+ * `InputView.initCompat()`用于兼容已有的[WindowInsets]处理方案。
19+ *
20+ * @author xcc
21+ * @date 2023/12/31
22+ */
23+ class InitCompatActivity : AppCompatActivity (), SystemBar {
24+ init {
25+ systemBarController {
26+ statusBarColor = 0xFFA2B4C0 .toInt()
27+ navigationBarEdgeToEdge = EdgeToEdge .Gesture
28+ isAppearanceLightStatusBar = true
29+ }
30+ }
31+
32+ override fun onCreate (savedInstanceState : Bundle ? ) {
33+ super .onCreate(savedInstanceState)
34+ // initCompat()不处理WindowInsets,仅完成window的初始化
35+ InputView .initCompat(window, gestureNavBarEdgeToEdge = true )
36+ setContentView(MessageListBinding .inflate(layoutInflater).init (window).root)
37+ }
38+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ class MainActivity : AppCompatActivity() {
3535 startActivity(Intent (this , ImeAnimatorActivity ::class .java))
3636 }
3737
38+ fun startInitCompatActivity (view : View ) {
39+ startActivity(Intent (this , InitCompatActivity ::class .java))
40+ }
41+
3842 fun startMessageListActivity (view : View ) {
3943 startActivity(Intent (this , MessageListActivity ::class .java))
4044 }
Original file line number Diff line number Diff line change 2121 android : text =" ImeAnimator"
2222 android : textAllCaps =" false" />
2323
24+ <Button
25+ android : layout_width =" wrap_content"
26+ android : layout_height =" wrap_content"
27+ android : layout_marginBottom =" 5dp"
28+ android : onClick =" startInitCompatActivity"
29+ android : text =" InitCompat"
30+ android : textAllCaps =" false" />
31+
2432 <Button
2533 android : layout_width =" wrap_content"
2634 android : layout_height =" wrap_content"
You can’t perform that action at this time.
0 commit comments