Improve layout further

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-07-03 21:51:14 +02:00
parent 370f256088
commit 654c46edc4
4 changed files with 10 additions and 6 deletions

View File

@ -471,7 +471,7 @@ public class CallsListController extends BaseController implements SearchView.On
bottomSheet = new BottomSheet.Builder(getActivity()).setView(view).create();
}
bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout()));
bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true));
bottomSheet.show();
}

View File

@ -423,7 +423,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
}
if (getActivity() != null) {
new KeyboardUtils(getActivity(), getView());
new KeyboardUtils(getActivity(), getView(), false);
}
}

View File

@ -31,6 +31,7 @@ import android.view.inputmethod.InputMethodManager;
public class KeyboardUtils {
private View decorView;
private View contentView;
private boolean isUsedInBottomSheet;
//a small helper to allow showing the editText focus
ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
@ -44,9 +45,9 @@ public class KeyboardUtils {
int diff = height - r.bottom;
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)
boolean shouldSetBottomPadding = (isUsedInBottomSheet && diff != 0) || (diff > 0);
if (shouldSetBottomPadding) {
if (contentView.getPaddingBottom() != diff) {
//set the padding of the contentView for the keyboard
contentView.setPadding(0, 0, 0, diff);
@ -61,9 +62,10 @@ public class KeyboardUtils {
}
};
public KeyboardUtils(Activity act, View contentView) {
public KeyboardUtils(Activity act, View contentView, boolean isUsedInBottomSheet) {
this.decorView = act.getWindow().getDecorView();
this.contentView = contentView;
this.isUsedInBottomSheet = isUsedInBottomSheet;
decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
}

View File

@ -28,6 +28,7 @@
android:id="@+id/messagesListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:layout_above="@+id/messageInputView"
app:incomingDefaultBubbleColor="@color/white_two"
app:incomingDefaultBubblePressedColor="@color/white_two"
@ -52,6 +53,7 @@
app:outcomingTextSize="@dimen/chat_text_size"
app:outcomingTimeTextColor="@color/warm_grey_four"
app:outcomingTimeTextSize="12sp"
app:dateHeaderTextSize="13sp"
app:textAutoLink="all"/>
<com.webianks.library.PopupBubble