mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Disable hardware acceleration and keyboard animation (#6535)
Some checks are pending
Android CI / Run tests and generate APK (push) Waiting to run
Some checks are pending
Android CI / Run tests and generate APK (push) Waiting to run
* Disable hardware acceleration and keyboard animation This is a temporary commit to see if it fixes issue #3364 * Remove unused import * Bump up version code and modify version name * Modify handleKeyboardInsets to handle insets correctly * Refactor handleKeyboardInsets() * Refactor handleKeyboardInsets() * Fix inset in login activity
This commit is contained in:
parent
32ae406cca
commit
2d0255e5fb
4 changed files with 21 additions and 36 deletions
|
|
@ -84,6 +84,7 @@
|
|||
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
|
||||
<activity
|
||||
android:name=".auth.LoginActivity"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
@ -100,8 +101,9 @@
|
|||
android:name=".upload.UploadActivity"
|
||||
android:configChanges="orientation|screenSize|keyboard"
|
||||
android:exported="true"
|
||||
android:hardwareAccelerated="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<intent-filter android:label="@string/intent_share_upload_label">
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
|
|||
|
||||
binding = ActivityLoginBinding.inflate(layoutInflater)
|
||||
applyEdgeToEdgeAllInsets(binding!!.root)
|
||||
binding?.aboutPrivacyPolicy?.handleKeyboardInsets()
|
||||
binding!!.root.handleKeyboardInsets()
|
||||
with(binding!!) {
|
||||
setContentView(root)
|
||||
|
||||
|
|
|
|||
|
|
@ -166,46 +166,29 @@ fun applyEdgeToEdgeBottomInsets(view: View) = view.applyEdgeToEdgeInsets { inset
|
|||
* and accounts for navigation bar insets to avoid double offsets.
|
||||
*/
|
||||
fun View.handleKeyboardInsets() {
|
||||
var existingBottomMargin = 0
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
|
||||
existingBottomMargin = if (view.getTag(R.id.initial_margin_bottom) != null) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||
val existingBottomMargin = if (view.getTag(R.id.initial_margin_bottom) != null) {
|
||||
view.getTag(R.id.initial_margin_bottom) as Int
|
||||
} else {
|
||||
view.setTag(R.id.initial_margin_bottom, 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
|
||||
}
|
||||
|
||||
// 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