Skip to content

Commit

Permalink
Removing more unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
theproducer committed Dec 20, 2023
1 parent e4f61a3 commit 9f19a11
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 109 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.capacitorjs.plugins.keyboard;

import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;

Expand Down Expand Up @@ -39,7 +36,7 @@ public void setKeyboardEventListener(@Nullable KeyboardEventListener keyboardEve
static final String EVENT_KB_WILL_HIDE = "keyboardWillHide";
static final String EVENT_KB_DID_HIDE = "keyboardDidHide";

public Keyboard(AppCompatActivity activity, boolean resizeOnFullScreen) {
public Keyboard(AppCompatActivity activity) {
this.activity = activity;

//http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing
Expand Down Expand Up @@ -90,109 +87,6 @@ public void onEnd(@NonNull WindowInsetsAnimationCompat animation) {
}
}
);


// list =
// new ViewTreeObserver.OnGlobalLayoutListener() {
// int previousHeightDiff = 0;
//
// @Override
// public void onGlobalLayout() {
// Rect r = new Rect();
// //r will be populated with the coordinates of your view that area still visible.
// rootView.getWindowVisibleDisplayFrame(r);
//
// // cache properties for later use
// int rootViewHeight = rootView.getRootView().getHeight();
// int resultBottom = r.bottom;
// int screenHeight;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// Insets windowInsets = rootView.getRootWindowInsets().getInsetsIgnoringVisibility(WindowInsets.Type.systemBars());
// screenHeight = rootViewHeight;
// resultBottom = resultBottom + windowInsets.bottom;
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// WindowInsets windowInsets = rootView.getRootWindowInsets();
// int stableInsetBottom = getLegacyStableInsetBottom(windowInsets);
// screenHeight = rootViewHeight;
// resultBottom = resultBottom + stableInsetBottom;
// } else {
// Point size = getLegacySizePoint();
// screenHeight = size.y;
// }
//
// int heightDiff = screenHeight - resultBottom;
//
// int pixelHeightDiff = (int) (heightDiff / density);
//
// if (pixelHeightDiff > 100 && pixelHeightDiff != previousHeightDiff) { // if more than 100 pixels, its probably a keyboard...
// if (resizeOnFullScreen) {
// possiblyResizeChildOfContent(true);
// }
//
// if (keyboardEventListener != null) {
// keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_SHOW, pixelHeightDiff);
// keyboardEventListener.onKeyboardEvent(EVENT_KB_DID_SHOW, pixelHeightDiff);
// } else {
// Logger.warn("Native Keyboard Event Listener not found");
// }
// } else if (pixelHeightDiff != previousHeightDiff && (previousHeightDiff - pixelHeightDiff) > 100) {
// if (resizeOnFullScreen) {
// possiblyResizeChildOfContent(false);
// }
//
// if (keyboardEventListener != null) {
// keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_HIDE, 0);
// keyboardEventListener.onKeyboardEvent(EVENT_KB_DID_HIDE, 0);
// } else {
// Logger.warn("Native Keyboard Event Listener not found");
// }
// }
// previousHeightDiff = pixelHeightDiff;
// }
//
// private void possiblyResizeChildOfContent(boolean keyboardShown) {
// int usableHeightNow = keyboardShown ? computeUsableHeight() : -1;
// if (usableHeightPrevious != usableHeightNow) {
// frameLayoutParams.height = usableHeightNow;
// mChildOfContent.requestLayout();
// usableHeightPrevious = usableHeightNow;
// }
// }
//
// private int computeUsableHeight() {
// Rect r = new Rect();
// mChildOfContent.getWindowVisibleDisplayFrame(r);
// return isOverlays() ? r.bottom : r.height();
// }
//
// @SuppressWarnings("deprecation")
// private boolean isOverlays() {
// final Window window = activity.getWindow();
// return (
// (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) ==
// View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// );
// }
// };
// mChildOfContent = content.getChildAt(0);
// rootView.getViewTreeObserver().addOnGlobalLayoutListener(list);
// frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}

@SuppressWarnings("deprecation")
private int getLegacyStableInsetBottom(WindowInsets windowInsets) {
return windowInsets.getStableInsetBottom();
}

@SuppressWarnings("deprecation")
private Point getLegacySizePoint() {
// calculate screen height differently for android versions <23: Lollipop 5.x, Marshmallow 6.x
//http://stackoverflow.com/a/29257533/3642890 beware of nexus 5
Display display = activity.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size;
}

public void show() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public class KeyboardPlugin extends Plugin {
public void load() {
execute(
() -> {
boolean resizeOnFullScreen = getConfig().getBoolean("resizeOnFullScreen", false);
implementation = new Keyboard(getActivity(), resizeOnFullScreen);
implementation = new Keyboard(getActivity());
implementation.setKeyboardEventListener(this::onKeyboardEvent);
}
);
Expand Down

0 comments on commit 9f19a11

Please sign in to comment.