Skip to content

Commit 2d0255e

Browse files
Disable hardware acceleration and keyboard animation (#6535)
* 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
1 parent 32ae406 commit 2d0255e

File tree

4 files changed

+21
-36
lines changed

4 files changed

+21
-36
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ android {
2424
applicationId = "fr.free.nrw.commons"
2525
minSdk = 21
2626
targetSdk = 35
27-
versionCode = 1058
28-
versionName = "6.0.2"
27+
versionCode = 1059
28+
versionName = "6.1.0"
2929

3030
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
3131
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
8585
<activity
8686
android:name=".auth.LoginActivity"
87+
android:windowSoftInputMode="adjustPan"
8788
android:exported="true">
8889
<intent-filter>
8990
<category android:name="android.intent.category.LAUNCHER" />
@@ -100,8 +101,9 @@
100101
android:name=".upload.UploadActivity"
101102
android:configChanges="orientation|screenSize|keyboard"
102103
android:exported="true"
104+
android:hardwareAccelerated="false"
103105
android:icon="@mipmap/ic_launcher"
104-
android:windowSoftInputMode="adjustResize">
106+
android:windowSoftInputMode="adjustPan">
105107
<intent-filter android:label="@string/intent_share_upload_label">
106108
<action android:name="android.intent.action.SEND" />
107109

app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
8989

9090
binding = ActivityLoginBinding.inflate(layoutInflater)
9191
applyEdgeToEdgeAllInsets(binding!!.root)
92-
binding?.aboutPrivacyPolicy?.handleKeyboardInsets()
92+
binding!!.root.handleKeyboardInsets()
9393
with(binding!!) {
9494
setContentView(root)
9595

app/src/main/java/fr/free/nrw/commons/utils/EdgeToEdgeUtils.kt

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -166,46 +166,29 @@ fun applyEdgeToEdgeBottomInsets(view: View) = view.applyEdgeToEdgeInsets { inset
166166
* and accounts for navigation bar insets to avoid double offsets.
167167
*/
168168
fun View.handleKeyboardInsets() {
169-
var existingBottomMargin = 0
170-
171-
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
172-
existingBottomMargin = if (view.getTag(R.id.initial_margin_bottom) != null) {
169+
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
170+
val existingBottomMargin = if (view.getTag(R.id.initial_margin_bottom) != null) {
173171
view.getTag(R.id.initial_margin_bottom) as Int
174172
} else {
175173
view.setTag(R.id.initial_margin_bottom, view.marginBottom)
176174
view.marginBottom
177175
}
178176

177+
val lp = layoutParams as MarginLayoutParams
178+
179+
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
180+
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
181+
val imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime())
182+
val imeBottomMargin = imeInsets.bottom - navBarInsets.bottom
183+
184+
lp.bottomMargin = if (imeVisible && imeBottomMargin >= existingBottomMargin)
185+
imeBottomMargin + existingBottomMargin
186+
else existingBottomMargin
187+
188+
layoutParams = lp
189+
179190
WindowInsetsCompat.CONSUMED
180191
}
181-
182-
// Animate during IME transition
183-
ViewCompat.setWindowInsetsAnimationCallback(
184-
this,
185-
object : WindowInsetsAnimationCompat.Callback(
186-
DISPATCH_MODE_CONTINUE_ON_SUBTREE
187-
) {
188-
override fun onProgress(
189-
insets: WindowInsetsCompat,
190-
runningAnimations: MutableList<WindowInsetsAnimationCompat>
191-
): WindowInsetsCompat {
192-
val lp = layoutParams as MarginLayoutParams
193-
val navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
194-
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
195-
val imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime())
196-
197-
// Avoid extra space due to system nav bar when the keyboard is shown
198-
val imeBottomMargin = imeInsets.bottom - navBarInsets.bottom
199-
200-
lp.bottomMargin = if(imeVisible && imeBottomMargin >= existingBottomMargin)
201-
imeBottomMargin + existingBottomMargin
202-
else existingBottomMargin
203-
204-
layoutParams = lp
205-
return WindowInsetsCompat.CONSUMED
206-
}
207-
}
208-
)
209192
}
210193

211194
/**

0 commit comments

Comments
 (0)