mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 04:13:53 +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
|
|
@ -24,8 +24,8 @@ android {
|
||||||
applicationId = "fr.free.nrw.commons"
|
applicationId = "fr.free.nrw.commons"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1058
|
versionCode = 1059
|
||||||
versionName = "6.0.2"
|
versionName = "6.1.0"
|
||||||
|
|
||||||
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@
|
||||||
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
|
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".auth.LoginActivity"
|
android:name=".auth.LoginActivity"
|
||||||
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|
@ -100,8 +101,9 @@
|
||||||
android:name=".upload.UploadActivity"
|
android:name=".upload.UploadActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboard"
|
android:configChanges="orientation|screenSize|keyboard"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
android:hardwareAccelerated="false"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustPan">
|
||||||
<intent-filter android:label="@string/intent_share_upload_label">
|
<intent-filter android:label="@string/intent_share_upload_label">
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
|
||||||
|
|
||||||
binding = ActivityLoginBinding.inflate(layoutInflater)
|
binding = ActivityLoginBinding.inflate(layoutInflater)
|
||||||
applyEdgeToEdgeAllInsets(binding!!.root)
|
applyEdgeToEdgeAllInsets(binding!!.root)
|
||||||
binding?.aboutPrivacyPolicy?.handleKeyboardInsets()
|
binding!!.root.handleKeyboardInsets()
|
||||||
with(binding!!) {
|
with(binding!!) {
|
||||||
setContentView(root)
|
setContentView(root)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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