mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 03:39:19 +01:00
Using adjust nothing softinput mode for Android 11
Setting category controller to auto adjust itself
This commit is contained in:
parent
a7c01684bf
commit
11467cdb01
@ -39,7 +39,7 @@
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
<activity
|
||||
android:name=".ui.main.MainActivity"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:windowSoftInputMode="adjustNothing"
|
||||
android:label="@string/app_short_name"
|
||||
android:theme="@style/Theme.Splash">
|
||||
<intent-filter>
|
||||
|
@ -58,7 +58,7 @@ class CategoryController(bundle: Bundle? = null) :
|
||||
*/
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
liftAppbarWith(binding.recycler)
|
||||
liftAppbarWith(binding.recycler, true)
|
||||
|
||||
adapter = CategoryAdapter(this@CategoryController)
|
||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
|
@ -169,6 +169,9 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
|
||||
R.drawable.ic_close_24dp
|
||||
)
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
||||
}
|
||||
var continueSwitchingTabs = false
|
||||
nav.getItemView(R.id.nav_library)?.setOnLongClickListener {
|
||||
if (!LibraryUpdateService.isRunning()) {
|
||||
|
@ -109,16 +109,21 @@ fun Controller.liftAppbarWith(recycler: RecyclerView, padView: Boolean = false)
|
||||
recycler.updatePaddingRelative(
|
||||
top = activityBinding!!.toolbar.y.toInt() + appBarHeight
|
||||
)
|
||||
recycler.applyBottomAnimatedInsets(setPadding = true)
|
||||
recycler.doOnApplyWindowInsets { view, insets, _ ->
|
||||
val headerHeight = insets.systemWindowInsetTop + appBarHeight
|
||||
view.updatePaddingRelative(
|
||||
top = headerHeight,
|
||||
bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.ime() or WindowInsets.Type.systemBars()).bottom
|
||||
} else {
|
||||
insets.systemWindowInsetBottom
|
||||
}
|
||||
top = headerHeight
|
||||
)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
view.updatePaddingRelative(
|
||||
bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.ime() or WindowInsets.Type.systemBars()).bottom
|
||||
} else {
|
||||
insets.systemWindowInsetBottom
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view?.applyWindowInsetsForController()
|
||||
|
@ -123,16 +123,20 @@ object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||
}
|
||||
}
|
||||
|
||||
fun View.applyBottomAnimatedInsets(bottomMargin: Int = 0) {
|
||||
fun View.applyBottomAnimatedInsets(bottomMargin: Int = 0, setPadding: Boolean = false) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return
|
||||
val setInsets: ((WindowInsets) -> Unit) = { insets ->
|
||||
updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
val bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.systemBars() or WindowInsets.Type.ime()).bottom
|
||||
} else {
|
||||
insets.systemWindowInsetBottom
|
||||
val bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.systemBars() or WindowInsets.Type.ime()).bottom
|
||||
} else {
|
||||
insets.systemWindowInsetBottom
|
||||
}
|
||||
if (setPadding) {
|
||||
updatePaddingRelative(bottom = bottomMargin + bottom)
|
||||
} else {
|
||||
updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
this.bottomMargin = bottom + bottomMargin
|
||||
}
|
||||
this.bottomMargin = bottom + bottomMargin
|
||||
}
|
||||
}
|
||||
var handleInsets = true
|
||||
|
Loading…
Reference in New Issue
Block a user