mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Compare commits
No commits in common. "c09365737f41d102925ae512eff7f3a96cc2073f" and "8e6db87f6eb07e667343569db50c7f9bb63eff3f" have entirely different histories.
c09365737f
...
8e6db87f6e
5 changed files with 32 additions and 19 deletions
|
|
@ -89,7 +89,6 @@ 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,7 +70,6 @@ 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,7 +70,6 @@ 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,7 +146,6 @@ 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,29 +166,46 @@ 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() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
var existingBottomMargin = 0
|
||||||
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