|
@@ -18,7 +18,6 @@ package com.nextcloud.talk.utils;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
import android.graphics.Rect;
|
|
|
-import android.os.Build;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewTreeObserver;
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
@@ -42,19 +41,19 @@ public class KeyboardUtils {
|
|
|
|
|
|
//get screen height and calculate the difference with the useable area from the r
|
|
|
int height = decorView.getContext().getResources().getDisplayMetrics().heightPixels;
|
|
|
+
|
|
|
int diff = height - r.bottom;
|
|
|
|
|
|
- //if it could be a keyboard add the padding to the view
|
|
|
- if (diff != 0) {
|
|
|
+ if (diff > 0) {
|
|
|
// if the use-able screen height differs from the total screen height we assume that it shows a keyboard now
|
|
|
//check if the padding is 0 (if yes set the padding for the keyboard)
|
|
|
if (contentView.getPaddingBottom() != diff) {
|
|
|
//set the padding of the contentView for the keyboard
|
|
|
- contentView.setPadding(0, 0, 0, diff);
|
|
|
+ contentView.setPadding(0, 0, 0, diff);
|
|
|
}
|
|
|
} else {
|
|
|
- //check if the padding is != 0 (if yes reset the padding)
|
|
|
- if (contentView.getPaddingBottom() != 0) {
|
|
|
+ //check if the padding is != initialBottomPadding (if yes reset the padding)
|
|
|
+ if (contentView.getPaddingBottom() != 0) {
|
|
|
//reset the padding of the contentView
|
|
|
contentView.setPadding(0, 0, 0, 0);
|
|
|
}
|
|
@@ -66,10 +65,7 @@ public class KeyboardUtils {
|
|
|
this.decorView = act.getWindow().getDecorView();
|
|
|
this.contentView = contentView;
|
|
|
|
|
|
- //only required on newer android versions. it was working on API level 19
|
|
|
- if (Build.VERSION.SDK_INT >= 19) {
|
|
|
- decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
- }
|
|
|
+ decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,14 +81,10 @@ public class KeyboardUtils {
|
|
|
}
|
|
|
|
|
|
public void enable() {
|
|
|
- if (Build.VERSION.SDK_INT >= 19) {
|
|
|
- decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
- }
|
|
|
+ decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
}
|
|
|
|
|
|
public void disable() {
|
|
|
- if (Build.VERSION.SDK_INT >= 19) {
|
|
|
- decorView.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
- }
|
|
|
+ decorView.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
}
|
|
|
}
|