From a2ad0394ced7f96386164e63794266b4dab1819e Mon Sep 17 00:00:00 2001 From: Srishti Rohatgi <53987325+srishti-R@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:44:41 +0530 Subject: [PATCH] fixes crash in sign up activity in api 21 and 22 (#5311) * fixes crash in sign up activity * javadoc comments added --- .../free/nrw/commons/auth/SignupActivity.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java b/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java index d6e4568fd..be90bb4bb 100644 --- a/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java @@ -1,5 +1,7 @@ package fr.free.nrw.commons.auth; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; @@ -61,4 +63,20 @@ public class SignupActivity extends BaseActivity { super.onBackPressed(); } } + + /** + * Known bug in androidx.appcompat library version 1.1.0 being tracked here + * https://issuetracker.google.com/issues/141132133 + * App tries to put light/dark theme to webview and crashes in the process + * This code tries to prevent applying the theme when sdk is between api 21 to 25 + * @param overrideConfiguration + */ + @Override + public void applyOverrideConfiguration(final Configuration overrideConfiguration) { + if (Build.VERSION.SDK_INT <= 25 && + (getResources().getConfiguration().uiMode == getApplicationContext().getResources().getConfiguration().uiMode)) { + return; + } + super.applyOverrideConfiguration(overrideConfiguration); + } }