This commit is contained in:
Niels Andriesse
2020-01-13 16:47:50 +11:00
parent df61e9565c
commit 52dc8d6b63
8 changed files with 36 additions and 21 deletions

View File

@@ -46,6 +46,8 @@ public class AttachmentTypeSelector extends PopupWindow {
@SuppressWarnings("unused")
private static final String TAG = AttachmentTypeSelector.class.getSimpleName();
private final @NonNull Context context;
public int keyboardHeight;
private final @NonNull LoaderManager loaderManager;
private final @NonNull RecentPhotoViewRail recentRail;
private final @NonNull ImageView imageButton;
@@ -63,6 +65,9 @@ public class AttachmentTypeSelector extends PopupWindow {
public AttachmentTypeSelector(@NonNull Context context, @NonNull LoaderManager loaderManager, @Nullable AttachmentClickedListener listener, int keyboardHeight) {
super(context);
this.context = context;
this.keyboardHeight = keyboardHeight;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.attachment_type_selector, null, true);
@@ -97,18 +102,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);
updateHeight();
loaderManager.initLoader(1, null, recentRail);
}
public void show(@NonNull Activity activity, final @NonNull View anchor) {
updateHeight();
if (Permissions.hasAll(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
recentRail.setVisibility(View.VISIBLE);
loaderManager.restartLoader(1, null, recentRail);
@@ -146,6 +147,16 @@ public class AttachmentTypeSelector extends PopupWindow {
}
}
private void updateHeight() {
int thresholdInDP = 120;
float scale = context.getResources().getDisplayMetrics().density;
int thresholdInPX = (int)(thresholdInDP * scale);
View contentView = ViewUtil.findById(getContentView(), R.id.contentView);
LinearLayout.LayoutParams contentViewLayoutParams = (LinearLayout.LayoutParams)contentView.getLayoutParams();
contentViewLayoutParams.height = keyboardHeight > thresholdInPX ? keyboardHeight : LinearLayout.LayoutParams.WRAP_CONTENT;
contentView.setLayoutParams(contentViewLayoutParams);
}
@Override
public void dismiss() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

View File

@@ -421,7 +421,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
View rootView = findViewById(R.id.rootView);
rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
int height = rootView.getRootView().getHeight() - rootView.getHeight();
expandedKeyboardHeight = Math.max(expandedKeyboardHeight, height);
int thresholdInDP = 120;
float scale = getResources().getDisplayMetrics().density;
int thresholdInPX = (int)(thresholdInDP * scale);
if (expandedKeyboardHeight == 0 || height > thresholdInPX) {
expandedKeyboardHeight = height;
}
collapsedKeyboardHeight = Math.min(collapsedKeyboardHeight, height);
keyboardHeight = Math.max(expandedKeyboardHeight - collapsedKeyboardHeight, keyboardHeight);
});
@@ -1175,6 +1180,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
if (attachmentTypeSelector == null) {
attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener(), keyboardHeight);
}
attachmentTypeSelector.keyboardHeight = keyboardHeight;
attachmentTypeSelector.show(this, attachButton);
} else {
handleManualMmsRequired();

View File

@@ -70,7 +70,7 @@ class FriendRequestView(context: Context, attrs: AttributeSet?, defStyleAttr: In
if (isUISetUp) { return }
isUISetUp = true
orientation = VERTICAL
setPadding(resources.getDimension(R.dimen.large_spacing).toInt(), 0, resources.getDimension(R.dimen.large_spacing).toInt(), 0)
setPadding(toPx(48, resources), 0, toPx(48, resources), 0)
addView(topSpacer)
addView(label)
if (!message!!.isOutgoing) {