Fix detecting software navbar height on emulator.

pull/89/head
Fox2Code 2 years ago
parent cab76ed4ff
commit f9e9559e93

@ -74,6 +74,9 @@ dependencies {
annotationProcessor "io.noties:prism4j-bundler:2.0.0"
implementation "com.caverock:androidsvg:1.4"
// Utils for compat
compileOnly "org.robolectric:android-all:11-robolectric-6757853"
// Test
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'

@ -10,6 +10,7 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyCharacterMap;
@ -88,8 +89,7 @@ public class CompatActivity extends AppCompatActivity {
if (!this.onCreateCalled) {
this.getLayoutInflater().setFactory2(new LayoutInflaterFactory(this.getDelegate())
.addOnViewCreatedListener(WindowInsetsHelper.Companion.getLISTENER()));
this.hasHardwareNavBar = ViewConfiguration.get(this).hasPermanentMenuKey() ||
KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
this.hasHardwareNavBar = this.hasHardwareNavBar0();
this.onCreateCalledOnce = true;
}
Application application = this.getApplication();
@ -104,6 +104,7 @@ public class CompatActivity extends AppCompatActivity {
@Override
protected void onResume() {
this.hasHardwareNavBar = this.hasHardwareNavBar0();
super.onResume();
this.refreshUI();
}
@ -287,9 +288,13 @@ public class CompatActivity extends AppCompatActivity {
public boolean hasHardwareNavBar() {
// If onCreate has not been called yet, cached value is not valid
return this.onCreateCalledOnce ? this.hasHardwareNavBar :
ViewConfiguration.get(this).hasPermanentMenuKey() ||
KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
return this.onCreateCalledOnce ? this.hasHardwareNavBar : this.hasHardwareNavBar0();
}
private boolean hasHardwareNavBar0() {
return (ViewConfiguration.get(this).hasPermanentMenuKey() ||
KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK)) &&
!"0".equals(SystemProperties.get("qemu.hw.mainkeys"));
}
public void setActionBarExtraMenuButton(@DrawableRes int drawableResId,

Loading…
Cancel
Save