Fix attachment type selector

This commit is contained in:
Niels Andriesse
2020-01-13 10:11:20 +11:00
parent c05c1eecd8
commit b75a15a063
4 changed files with 30 additions and 17 deletions

View File

@@ -26,10 +26,11 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.util.ViewUtil;
import network.loki.messenger.R;
public class AttachmentTypeSelector extends PopupWindow {
public static final int ADD_GALLERY = 1;
@@ -59,7 +60,7 @@ public class AttachmentTypeSelector extends PopupWindow {
private @Nullable View currentAnchor;
private @Nullable AttachmentClickedListener listener;
public AttachmentTypeSelector(@NonNull Context context, @NonNull LoaderManager loaderManager, @Nullable AttachmentClickedListener listener) {
public AttachmentTypeSelector(@NonNull Context context, @NonNull LoaderManager loaderManager, @Nullable AttachmentClickedListener listener, int keyboardHeight) {
super(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -96,6 +97,14 @@ public class AttachmentTypeSelector extends PopupWindow {
setFocusable(true);
setTouchable(true);
int thresholdInDP = 200;
float scale = context.getResources().getDisplayMetrics().density;
int thresholdInPX = (int)(thresholdInDP * scale);
View contentView = ViewUtil.findById(layout, R.id.contentView);
LinearLayout.LayoutParams contentViewLayoutParams = (LinearLayout.LayoutParams)contentView.getLayoutParams();
contentViewLayoutParams.height = keyboardHeight > thresholdInPX ? keyboardHeight : LinearLayout.LayoutParams.WRAP_CONTENT;
contentView.setLayoutParams(contentViewLayoutParams);
loaderManager.initLoader(1, null, recentRail);
}