mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Compare commits
3 commits
8e6db87f6e
...
c09365737f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c09365737f | ||
|
|
3f2c75ce11 | ||
|
|
ec9bb3f89b |
5 changed files with 19 additions and 32 deletions
|
|
@ -89,6 +89,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
|
||||||
|
|
||||||
binding = ActivityLoginBinding.inflate(layoutInflater)
|
binding = ActivityLoginBinding.inflate(layoutInflater)
|
||||||
applyEdgeToEdgeAllInsets(binding!!.root)
|
applyEdgeToEdgeAllInsets(binding!!.root)
|
||||||
|
binding?.aboutPrivacyPolicy?.handleKeyboardInsets()
|
||||||
with(binding!!) {
|
with(binding!!) {
|
||||||
setContentView(root)
|
setContentView(root)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ class UploadCategoriesFragment : UploadBaseFragment(), CategoriesContract.View {
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
binding = UploadCategoriesFragmentBinding.inflate(inflater, container, false)
|
binding = UploadCategoriesFragmentBinding.inflate(inflater, container, false)
|
||||||
|
binding!!.llContainerButtons.handleKeyboardInsets()
|
||||||
return binding!!.root
|
return binding!!.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ class DepictsFragment : UploadBaseFragment(), DepictsContract.View {
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
_binding = UploadDepictsFragmentBinding.inflate(inflater, container, false)
|
_binding = UploadDepictsFragmentBinding.inflate(inflater, container, false)
|
||||||
|
_binding!!.navigationButtonsContainer.handleKeyboardInsets()
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
_binding = FragmentUploadMediaDetailFragmentBinding.inflate(inflater, container, false)
|
_binding = FragmentUploadMediaDetailFragmentBinding.inflate(inflater, container, false)
|
||||||
|
_binding!!.mediaDetailCardView.handleKeyboardInsets()
|
||||||
// intialise the adapter early to prevent uninitialized access
|
// intialise the adapter early to prevent uninitialized access
|
||||||
uploadMediaDetailAdapter = UploadMediaDetailAdapter(
|
uploadMediaDetailAdapter = UploadMediaDetailAdapter(
|
||||||
this,
|
this,
|
||||||
|
|
|
||||||
|
|
@ -166,46 +166,29 @@ fun applyEdgeToEdgeBottomInsets(view: View) = view.applyEdgeToEdgeInsets { inset
|
||||||
* and accounts for navigation bar insets to avoid double offsets.
|
* and accounts for navigation bar insets to avoid double offsets.
|
||||||
*/
|
*/
|
||||||
fun View.handleKeyboardInsets() {
|
fun View.handleKeyboardInsets() {
|
||||||
var existingBottomMargin = 0
|
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||||
|
val existingBottomMargin = if (view.getTag(R.id.initial_margin_bottom) != null) {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
|
|
||||||
existingBottomMargin = if (view.getTag(R.id.initial_margin_bottom) != null) {
|
|
||||||
view.getTag(R.id.initial_margin_bottom) as Int
|
view.getTag(R.id.initial_margin_bottom) as Int
|
||||||
} else {
|
} else {
|
||||||
view.setTag(R.id.initial_margin_bottom, view.marginBottom)
|
view.setTag(R.id.initial_margin_bottom, view.marginBottom)
|
||||||
view.marginBottom
|
view.marginBottom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val lp = layoutParams as MarginLayoutParams
|
||||||
|
|
||||||
|
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
|
||||||
|
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
|
||||||
|
val imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime())
|
||||||
|
val imeBottomMargin = imeInsets.bottom - navBarInsets.bottom
|
||||||
|
|
||||||
|
lp.bottomMargin = if (imeVisible && imeBottomMargin >= existingBottomMargin)
|
||||||
|
imeBottomMargin + existingBottomMargin
|
||||||
|
else existingBottomMargin
|
||||||
|
|
||||||
|
layoutParams = lp
|
||||||
|
|
||||||
WindowInsetsCompat.CONSUMED
|
WindowInsetsCompat.CONSUMED
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animate during IME transition
|
|
||||||
ViewCompat.setWindowInsetsAnimationCallback(
|
|
||||||
this,
|
|
||||||
object : WindowInsetsAnimationCompat.Callback(
|
|
||||||
DISPATCH_MODE_CONTINUE_ON_SUBTREE
|
|
||||||
) {
|
|
||||||
override fun onProgress(
|
|
||||||
insets: WindowInsetsCompat,
|
|
||||||
runningAnimations: MutableList<WindowInsetsAnimationCompat>
|
|
||||||
): WindowInsetsCompat {
|
|
||||||
val lp = layoutParams as MarginLayoutParams
|
|
||||||
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
|
|
||||||
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
|
|
||||||
val imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime())
|
|
||||||
|
|
||||||
// Avoid extra space due to system nav bar when the keyboard is shown
|
|
||||||
val imeBottomMargin = imeInsets.bottom - navBarInsets.bottom
|
|
||||||
|
|
||||||
lp.bottomMargin = if(imeVisible && imeBottomMargin >= existingBottomMargin)
|
|
||||||
imeBottomMargin + existingBottomMargin
|
|
||||||
else existingBottomMargin
|
|
||||||
|
|
||||||
layoutParams = lp
|
|
||||||
return WindowInsetsCompat.CONSUMED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue