Fix white bar on top after Android 12 upgrade by @Helium314 (#238)

Co-authored-by: Helium314 <helium314@mailbox.org>
This commit is contained in:
BlackyHawky 2023-10-23 08:55:03 +02:00 committed by GitHub
parent c58bd52261
commit b1c1ea5fac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.inputmethodservice.InputMethodService;
import android.media.AudioManager;
import android.os.Build;
@ -56,8 +57,6 @@ import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import org.dslul.openboard.inputmethod.latin.common.Constants;
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
import org.dslul.openboard.inputmethod.latin.common.InputPointers;
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
import org.dslul.openboard.inputmethod.latin.common.StringUtilsKt;
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
import org.dslul.openboard.inputmethod.latin.define.ProductionFlags;
import org.dslul.openboard.inputmethod.latin.inputlogic.InputLogic;
@ -1077,8 +1076,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onWindowShown() {
super.onWindowShown();
if (isInputViewShown())
if (isInputViewShown()) {
setNavigationBarColor();
workaroundForHuaweiStatusBarIssue();
}
}
@Override
@ -2040,4 +2041,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
view.setSystemUiVisibility(mOriginalNavBarFlags);
}
// On HUAWEI devices with Android 12: a white bar may appear in landscape mode (issue #231)
// We therefore need to make the color of the status bar transparent
private void workaroundForHuaweiStatusBarIssue() {
final Window window = getWindow().getWindow();
if (window == null) {
return;
}
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && Build.MANUFACTURER.equals("HUAWEI")) {
window.setStatusBarColor(Color.TRANSPARENT);
}
}
}