This commit is contained in:
Horis 2024-09-07 12:12:23 +08:00
parent c131f6da9d
commit 46b47bec75
6 changed files with 25 additions and 17 deletions

View File

@ -8,7 +8,6 @@ import android.view.MenuItem
import android.widget.EditText
import androidx.activity.viewModels
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.tabs.TabLayout
@ -42,8 +41,10 @@ import io.legado.app.ui.widget.dialog.VariableDialog
import io.legado.app.ui.widget.keyboard.KeyboardToolPop
import io.legado.app.ui.widget.text.EditEntity
import io.legado.app.utils.GSON
import io.legado.app.utils.imeHeight
import io.legado.app.utils.isContentScheme
import io.legado.app.utils.launch
import io.legado.app.utils.navigationBarHeight
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.share
@ -201,10 +202,10 @@ class BookSourceEditActivity :
}
})
ViewCompat.setOnApplyWindowInsetsListener(binding.recyclerView) { _, windowInsets ->
val typeMask = WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.ime()
val insets = windowInsets.getInsets(typeMask)
binding.recyclerView.bottomPadding = insets.bottom
softKeyboardTool.initialPadding = insets.bottom
val navigationBarHeight = windowInsets.navigationBarHeight
val imeHeight = windowInsets.imeHeight
binding.recyclerView.bottomPadding = if (imeHeight == 0) navigationBarHeight else 0
softKeyboardTool.initialPadding = imeHeight
windowInsets
}
}

View File

@ -8,7 +8,6 @@ import android.view.MenuItem
import android.widget.EditText
import androidx.activity.viewModels
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -17,10 +16,10 @@ import io.legado.app.databinding.ActivityReplaceEditBinding
import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.ui.widget.keyboard.KeyboardToolPop
import io.legado.app.utils.GSON
import io.legado.app.utils.imeHeight
import io.legado.app.utils.sendToClip
import io.legado.app.utils.showHelp
import io.legado.app.utils.viewbindingdelegate.viewBinding
import splitties.views.bottomPadding
/**
* 编辑替换规则
@ -93,10 +92,7 @@ class ReplaceEditActivity :
showHelp("regexHelp")
}
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, windowInsets ->
val typeMask = WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.ime()
val insets = windowInsets.getInsets(typeMask)
binding.root.bottomPadding = insets.bottom
softKeyboardTool.initialPadding = insets.bottom
softKeyboardTool.initialPadding = windowInsets.imeHeight
windowInsets
}
}

View File

@ -7,7 +7,6 @@ import android.view.MenuItem
import android.widget.EditText
import androidx.activity.viewModels
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.google.android.material.tabs.TabLayout
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
@ -30,9 +29,11 @@ import io.legado.app.ui.widget.dialog.VariableDialog
import io.legado.app.ui.widget.keyboard.KeyboardToolPop
import io.legado.app.ui.widget.text.EditEntity
import io.legado.app.utils.GSON
import io.legado.app.utils.imeHeight
import io.legado.app.utils.isContentScheme
import io.legado.app.utils.isTrue
import io.legado.app.utils.launch
import io.legado.app.utils.navigationBarHeight
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.share
@ -189,10 +190,10 @@ class RssSourceEditActivity :
}
})
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, windowInsets ->
val typeMask = WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.ime()
val insets = windowInsets.getInsets(typeMask)
binding.root.bottomPadding = insets.bottom
softKeyboardTool.initialPadding = insets.bottom
val navigationBarHeight = windowInsets.navigationBarHeight
val imeHeight = windowInsets.imeHeight
binding.recyclerView.bottomPadding = if (imeHeight == 0) navigationBarHeight else 0
softKeyboardTool.initialPadding = imeHeight
windowInsets
}
}

View File

@ -83,7 +83,7 @@ class KeyboardToolPop(
}
} else {
mIsSoftKeyBoardShowing = false
//rootView.setPadding(0, 0, 0, 0)
rootView.setPadding(0, 0, 0, 0)
if (preShowing) {
dismiss()
}

View File

@ -0,0 +1,9 @@
package io.legado.app.utils
import androidx.core.view.WindowInsetsCompat
val WindowInsetsCompat.navigationBarHeight
get() = getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
val WindowInsetsCompat.imeHeight
get() = getInsets(WindowInsetsCompat.Type.ime()).bottom

View File

@ -67,6 +67,7 @@
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_source_edit" />