diff --git a/res/layout/attachment_type_selector.xml b/res/layout/attachment_type_selector.xml index 1b145d5bd8..a09ca2d5e6 100644 --- a/res/layout/attachment_type_selector.xml +++ b/res/layout/attachment_type_selector.xml @@ -12,9 +12,11 @@ android:background="@drawable/attachment_selector_shadow"/> - diff --git a/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java b/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java index 3c706d0f48..a1deeda36b 100644 --- a/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java +++ b/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java @@ -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); } diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index aee817b698..99cda5cd83 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -223,7 +223,6 @@ import org.whispersystems.signalservice.loki.api.LokiStorageAPI; import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus; import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus; import org.whispersystems.signalservice.loki.messaging.Mention; -import org.whispersystems.signalservice.loki.utilities.Analytics; import java.io.IOException; import java.text.SimpleDateFormat; @@ -330,9 +329,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private int distributionType; private boolean archived; private boolean isSecureText; - private boolean isDefaultSms = true; - private boolean isMmsEnabled = true; - private boolean isSecurityInitialized = false; + private boolean isDefaultSms = true; + private boolean isMmsEnabled = true; + private boolean isSecurityInitialized = false; + private int expandedKeyboardHeight = 0; + private int collapsedKeyboardHeight = Integer.MAX_VALUE; + private int keyboardHeight = 0; private final IdentityRecordList identityRecords = new IdentityRecordList(); private final DynamicNoActionBarTheme dynamicTheme = new DynamicNoActionBarTheme(); @@ -416,15 +418,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity LokiAPIUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, this); - if (this.recipient.isGroupRecipient()) { - if (this.recipient.getName().equals("Loki Public Chat")) { - Analytics.Companion.getShared().track("Loki Public Chat Opened"); - } else { - Analytics.Companion.getShared().track("RSS Feed Opened"); - } - } else { - Analytics.Companion.getShared().track("Conversation Opened"); - } + View rootView = findViewById(R.id.rootView); + rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> { + int height = rootView.getRootView().getHeight() - rootView.getHeight(); + expandedKeyboardHeight = Math.max(expandedKeyboardHeight, height); + collapsedKeyboardHeight = Math.min(collapsedKeyboardHeight, height); + keyboardHeight = Math.max(expandedKeyboardHeight - collapsedKeyboardHeight, keyboardHeight); + }); } @Override @@ -1173,7 +1173,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private void handleAddAttachment() { if (this.isMmsEnabled || isSecureText) { if (attachmentTypeSelector == null) { - attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener()); + attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener(), keyboardHeight); } attachmentTypeSelector.show(this, attachButton); } else {