mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 05:59:17 +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">
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.main.MainActivity"
|
android:name=".ui.main.MainActivity"
|
||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustNothing"
|
||||||
android:label="@string/app_short_name"
|
android:label="@string/app_short_name"
|
||||||
android:theme="@style/Theme.Splash">
|
android:theme="@style/Theme.Splash">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -58,7 +58,7 @@ class CategoryController(bundle: Bundle? = null) :
|
|||||||
*/
|
*/
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
liftAppbarWith(binding.recycler)
|
liftAppbarWith(binding.recycler, true)
|
||||||
|
|
||||||
adapter = CategoryAdapter(this@CategoryController)
|
adapter = CategoryAdapter(this@CategoryController)
|
||||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
|
@ -169,6 +169,9 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
|
|||||||
R.drawable.ic_close_24dp
|
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
|
var continueSwitchingTabs = false
|
||||||
nav.getItemView(R.id.nav_library)?.setOnLongClickListener {
|
nav.getItemView(R.id.nav_library)?.setOnLongClickListener {
|
||||||
if (!LibraryUpdateService.isRunning()) {
|
if (!LibraryUpdateService.isRunning()) {
|
||||||
|
@ -109,10 +109,14 @@ fun Controller.liftAppbarWith(recycler: RecyclerView, padView: Boolean = false)
|
|||||||
recycler.updatePaddingRelative(
|
recycler.updatePaddingRelative(
|
||||||
top = activityBinding!!.toolbar.y.toInt() + appBarHeight
|
top = activityBinding!!.toolbar.y.toInt() + appBarHeight
|
||||||
)
|
)
|
||||||
|
recycler.applyBottomAnimatedInsets(setPadding = true)
|
||||||
recycler.doOnApplyWindowInsets { view, insets, _ ->
|
recycler.doOnApplyWindowInsets { view, insets, _ ->
|
||||||
val headerHeight = insets.systemWindowInsetTop + appBarHeight
|
val headerHeight = insets.systemWindowInsetTop + appBarHeight
|
||||||
view.updatePaddingRelative(
|
view.updatePaddingRelative(
|
||||||
top = headerHeight,
|
top = headerHeight
|
||||||
|
)
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
view.updatePaddingRelative(
|
||||||
bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
insets.getInsets(WindowInsets.Type.ime() or WindowInsets.Type.systemBars()).bottom
|
insets.getInsets(WindowInsets.Type.ime() or WindowInsets.Type.systemBars()).bottom
|
||||||
} else {
|
} else {
|
||||||
@ -120,6 +124,7 @@ fun Controller.liftAppbarWith(recycler: RecyclerView, padView: Boolean = false)
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
view?.applyWindowInsetsForController()
|
view?.applyWindowInsetsForController()
|
||||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||||
|
@ -123,18 +123,22 @@ 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
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return
|
||||||
val setInsets: ((WindowInsets) -> Unit) = { insets ->
|
val setInsets: ((WindowInsets) -> Unit) = { insets ->
|
||||||
updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
|
||||||
val bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
val bottom = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
insets.getInsets(WindowInsets.Type.systemBars() or WindowInsets.Type.ime()).bottom
|
insets.getInsets(WindowInsets.Type.systemBars() or WindowInsets.Type.ime()).bottom
|
||||||
} else {
|
} else {
|
||||||
insets.systemWindowInsetBottom
|
insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
|
if (setPadding) {
|
||||||
|
updatePaddingRelative(bottom = bottomMargin + bottom)
|
||||||
|
} else {
|
||||||
|
updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
this.bottomMargin = bottom + bottomMargin
|
this.bottomMargin = bottom + bottomMargin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var handleInsets = true
|
var handleInsets = true
|
||||||
doOnApplyWindowInsets { _, insets, _ ->
|
doOnApplyWindowInsets { _, insets, _ ->
|
||||||
if (handleInsets) {
|
if (handleInsets) {
|
||||||
|
Loading…
Reference in New Issue
Block a user