Skip to content

Commit

Permalink
Workaround android 15 edge-to-edge
Browse files Browse the repository at this point in the history
  • Loading branch information
rkkr committed Oct 30, 2024
1 parent 20ef92b commit b4a4c03
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
compileSdk 35
minSdkVersion 15
targetSdkVersion 35
versionCode 9
versionName "0.9"
versionCode 10
versionName "0.10"
}
buildTypes {
release {
Expand Down
21 changes: 14 additions & 7 deletions app/src/main/java/rkr/tinykeyboard/inputmethod/SoftKeyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class SoftKeyboard extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {

private InputMethodManager mInputMethodManager;

private KeyboardView mInputView;
private static android.graphics.Insets mInsets;

private int mLastDisplayWidth;
private boolean mCapsLock;
Expand Down Expand Up @@ -91,20 +91,27 @@ Context getDisplayContext() {
mInputView.setOnKeyboardActionListener(this);
mInputView.setPreviewEnabled(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
setLayoutParams(mInputView);
mInputView.setOnApplyWindowInsetsListener((view, windowInsets) -> {
android.graphics.Insets insets = windowInsets.getInsets(WindowInsets.Type.systemBars());
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
mlp.leftMargin = insets.left;
mlp.bottomMargin = insets.bottom;
mlp.rightMargin = insets.right;
view.setLayoutParams(mlp);
mInsets = windowInsets.getInsets(WindowInsets.Type.systemBars());
setLayoutParams(mInputView);
return WindowInsets.CONSUMED;
});
}
setLatinKeyboard(mQwertyKeyboard);
return mInputView;
}

private void setLayoutParams(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && mInsets != null) {
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
mlp.leftMargin = mInsets.left;
mlp.bottomMargin = mInsets.bottom;
mlp.rightMargin = mInsets.right;
view.setLayoutParams(mlp);
}
}

private void setLatinKeyboard(LatinKeyboard nextKeyboard) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
final boolean shouldSupportLanguageSwitchKey = mInputMethodManager.shouldOfferSwitchingToNextInputMethod(getToken());
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:8.6.0'
classpath 'com.android.tools.build:gradle:8.7.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip

0 comments on commit b4a4c03

Please sign in to comment.