Skip to content

Commit e2dd73d

Browse files
Revert "fix(android): fixed issues on android 15+ white space above keyboard" (#2387)
1 parent 2faaa4f commit e2dd73d

File tree

2 files changed

+4
-37
lines changed

2 files changed

+4
-37
lines changed

keyboard/android/src/main/java/com/capacitorjs/plugins/keyboard/Keyboard.java

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import android.content.Context;
44
import android.graphics.Rect;
5-
import android.os.Build;
65
import android.util.DisplayMetrics;
7-
import android.util.TypedValue;
86
import android.view.View;
97
import android.view.Window;
108
import android.view.inputmethod.InputMethodManager;
@@ -15,7 +13,6 @@
1513
import androidx.core.view.ViewCompat;
1614
import androidx.core.view.WindowInsetsAnimationCompat;
1715
import androidx.core.view.WindowInsetsCompat;
18-
import com.getcapacitor.Bridge;
1916
import java.util.List;
2017

2118
public class Keyboard {
@@ -24,7 +21,6 @@ interface KeyboardEventListener {
2421
void onKeyboardEvent(String event, int size);
2522
}
2623

27-
private Bridge bridge;
2824
private AppCompatActivity activity;
2925
private View rootView;
3026
private int usableHeightPrevious;
@@ -43,9 +39,8 @@ public void setKeyboardEventListener(@Nullable KeyboardEventListener keyboardEve
4339
static final String EVENT_KB_WILL_HIDE = "keyboardWillHide";
4440
static final String EVENT_KB_DID_HIDE = "keyboardDidHide";
4541

46-
public Keyboard(Bridge bridge, boolean resizeOnFullScreen) {
47-
this.bridge = bridge;
48-
this.activity = this.bridge.getActivity();
42+
public Keyboard(AppCompatActivity activity, boolean resizeOnFullScreen) {
43+
this.activity = activity;
4944

5045
//http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing
5146
FrameLayout content = activity.getWindow().getDecorView().findViewById(android.R.id.content);
@@ -136,38 +131,9 @@ private void possiblyResizeChildOfContent(boolean keyboardShown) {
136131
private int computeUsableHeight() {
137132
Rect r = new Rect();
138133
mChildOfContent.getWindowVisibleDisplayFrame(r);
139-
if (shouldApplyEdgeToEdgeAdjustments()) {
140-
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(rootView);
141-
if (insets != null) {
142-
int systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
143-
if (systemBars > 0) {
144-
return r.bottom + systemBars;
145-
}
146-
}
147-
}
148-
149134
return isOverlays() ? r.bottom : r.height();
150135
}
151136

152-
private boolean shouldApplyEdgeToEdgeAdjustments() {
153-
var adjustMarginsForEdgeToEdge = this.bridge.getConfig().adjustMarginsForEdgeToEdge();
154-
if (adjustMarginsForEdgeToEdge.equals("force")) { // Force edge-to-edge adjustments regardless of app settings
155-
return true;
156-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM && adjustMarginsForEdgeToEdge.equals("auto")) { // Auto means that we need to check the app's edge-to-edge preference
157-
TypedValue value = new TypedValue();
158-
boolean optOutAttributeExists = activity
159-
.getTheme()
160-
.resolveAttribute(android.R.attr.windowOptOutEdgeToEdgeEnforcement, value, true);
161-
162-
if (!optOutAttributeExists) { // Default is to apply edge to edge
163-
return true;
164-
} else {
165-
return value.data == 0;
166-
}
167-
}
168-
return false;
169-
}
170-
171137
@SuppressWarnings("deprecation")
172138
private boolean isOverlays() {
173139
final Window window = activity.getWindow();

keyboard/android/src/main/java/com/capacitorjs/plugins/keyboard/KeyboardPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public void load() {
1818
execute(
1919
() -> {
2020
boolean resizeOnFullScreen = getConfig().getBoolean("resizeOnFullScreen", false);
21-
implementation = new Keyboard(bridge, resizeOnFullScreen);
21+
implementation = new Keyboard(getActivity(), resizeOnFullScreen);
22+
2223
implementation.setKeyboardEventListener(this::onKeyboardEvent);
2324
}
2425
);

0 commit comments

Comments
 (0)