边距问题 #269
This commit is contained in:
@@ -97,7 +97,7 @@ abstract class BaseActivity<VB : ViewBinding>(
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q)
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
enableEdgeToEdge()
|
||||
else{
|
||||
setupSystemBar()
|
||||
|
||||
@@ -4,6 +4,7 @@ package io.legado.app.ui.main
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.Gravity
|
||||
@@ -12,6 +13,7 @@ import android.view.MotionEvent
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.get
|
||||
@@ -129,7 +131,8 @@ open class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
if (savedInstanceState != null) {
|
||||
pagePosition = savedInstanceState.getInt("currentPagePosition", 0)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S)
|
||||
binding.viewPagerMain.fitsSystemWindows = true
|
||||
// 其他初始化逻辑
|
||||
setupBackCallback()
|
||||
upBottomMenu()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package io.legado.app.ui.main.bookshelf.books
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.SearchView
|
||||
@@ -53,6 +54,8 @@ class BookshelfFragment1() : BaseBookshelfFragment(R.layout.fragment_bookshelf1)
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
setSupportToolbar(binding.topBar)
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
binding.titleBar.fitsSystemWindows = true
|
||||
initView()
|
||||
initBookGroupData()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.legado.app.ui.main.bookshelf.books
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
@@ -120,6 +121,8 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
||||
initBookGroupData()
|
||||
initAllBooksData()
|
||||
initBooksData()
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
binding.titleBar.fitsSystemWindows = true
|
||||
backCallback = object : OnBackPressedCallback(false) { // 初始禁用
|
||||
override fun handleOnBackPressed() {
|
||||
if (back()) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package io.legado.app.ui.main.bookshelf.books
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.SearchView
|
||||
@@ -50,6 +51,8 @@ class BookshelfFragment3() : BaseBookshelfFragment(R.layout.fragment_bookshelf3)
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
setSupportToolbar(binding.topBar)
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
binding.titleBar.fitsSystemWindows = true
|
||||
initView()
|
||||
initBookGroupData()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.legado.app.ui.main.explore
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
@@ -74,6 +75,8 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
|
||||
initRecyclerView()
|
||||
initGroupData()
|
||||
upExploreData()
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
binding.appBar.fitsSystemWindows = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.legado.app.ui.main.my
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
@@ -56,6 +57,8 @@ class MyFragment() : BaseFragment(R.layout.fragment_my_config), MainFragmentInte
|
||||
if (preferenceFragment == null) preferenceFragment = MyPreferenceFragment()
|
||||
childFragmentManager.beginTransaction()
|
||||
.replace(R.id.pre_fragment, preferenceFragment, fragmentTag).commit()
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
binding.titleBar.fitsSystemWindows = true
|
||||
}
|
||||
|
||||
override fun onCompatCreateOptionsMenu(menu: Menu) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.legado.app.ui.main.rss
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.transition.TransitionManager
|
||||
import android.view.Menu
|
||||
@@ -72,6 +73,8 @@ class RssFragment() : VMBaseFragment<RssViewModel>(R.layout.fragment_rss),
|
||||
initRecyclerView()
|
||||
initGroupData()
|
||||
upRssFlowJob()
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
binding.appBar.fitsSystemWindows = true
|
||||
}
|
||||
|
||||
override fun onCompatCreateOptionsMenu(menu: Menu) {
|
||||
|
||||
@@ -146,12 +146,13 @@ fun Activity.setLightStatusBar(isLightBar: Boolean) {
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
fun Window.setNavigationBarColorAuto(@ColorInt color: Int) {
|
||||
val isLightBor = ColorUtils.isColorLight(color)
|
||||
if (Build.VERSION.SDK_INT >= 35) return
|
||||
val isLightBar = ColorUtils.isColorLight(color)
|
||||
navigationBarColor = color
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insetsController?.let {
|
||||
if (isLightBor) {
|
||||
if (isLightBar) {
|
||||
it.setSystemBarsAppearance(
|
||||
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
|
||||
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
|
||||
@@ -163,21 +164,19 @@ fun Window.setNavigationBarColorAuto(@ColorInt color: Int) {
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if (Build.VERSION.SDK_INT in Build.VERSION_CODES.O..Build.VERSION_CODES.Q) {
|
||||
var systemUiVisibility = decorView.systemUiVisibility
|
||||
systemUiVisibility = if (isLightBor) {
|
||||
systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
} else{
|
||||
var flags = decorView.systemUiVisibility
|
||||
flags = if (isLightBar) {
|
||||
flags or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
} else {
|
||||
systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
|
||||
flags and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
|
||||
}
|
||||
decorView.systemUiVisibility = systemUiVisibility
|
||||
decorView.systemUiVisibility = flags
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun Activity.keepScreenOn(on: Boolean) {
|
||||
val isScreenOn =
|
||||
(window.attributes.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/navigation_rail_view"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
tools:ignore="SpeakableTextPresentCheck" />
|
||||
|
||||
<!-- 底部导航栏 -->
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:stateListAnimator="@null"
|
||||
app:liftOnScroll="false">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user