mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 21:53:43 +00:00
Fix attachment type selector
This commit is contained in:
parent
c05c1eecd8
commit
b75a15a063
@ -12,9 +12,11 @@
|
|||||||
android:background="@drawable/attachment_selector_shadow"/>
|
android:background="@drawable/attachment_selector_shadow"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/contentView"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:background="?attachment_type_selector_background">
|
android:background="?attachment_type_selector_background">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.RecentPhotoViewRail
|
<org.thoughtcrime.securesms.components.RecentPhotoViewRail
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/rootView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/default_session_background">
|
android:background="@drawable/default_session_background">
|
||||||
|
@ -26,10 +26,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
|
||||||
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
public class AttachmentTypeSelector extends PopupWindow {
|
public class AttachmentTypeSelector extends PopupWindow {
|
||||||
|
|
||||||
public static final int ADD_GALLERY = 1;
|
public static final int ADD_GALLERY = 1;
|
||||||
@ -59,7 +60,7 @@ public class AttachmentTypeSelector extends PopupWindow {
|
|||||||
private @Nullable View currentAnchor;
|
private @Nullable View currentAnchor;
|
||||||
private @Nullable AttachmentClickedListener listener;
|
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);
|
super(context);
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
@ -96,6 +97,14 @@ public class AttachmentTypeSelector extends PopupWindow {
|
|||||||
setFocusable(true);
|
setFocusable(true);
|
||||||
setTouchable(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);
|
loaderManager.initLoader(1, null, recentRail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,6 @@ import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
|||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
||||||
import org.whispersystems.signalservice.loki.messaging.Mention;
|
import org.whispersystems.signalservice.loki.messaging.Mention;
|
||||||
import org.whispersystems.signalservice.loki.utilities.Analytics;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -333,6 +332,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private boolean isDefaultSms = true;
|
private boolean isDefaultSms = true;
|
||||||
private boolean isMmsEnabled = true;
|
private boolean isMmsEnabled = true;
|
||||||
private boolean isSecurityInitialized = false;
|
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 IdentityRecordList identityRecords = new IdentityRecordList();
|
||||||
private final DynamicNoActionBarTheme dynamicTheme = new DynamicNoActionBarTheme();
|
private final DynamicNoActionBarTheme dynamicTheme = new DynamicNoActionBarTheme();
|
||||||
@ -416,15 +418,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
LokiAPIUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, this);
|
LokiAPIUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, this);
|
||||||
|
|
||||||
if (this.recipient.isGroupRecipient()) {
|
View rootView = findViewById(R.id.rootView);
|
||||||
if (this.recipient.getName().equals("Loki Public Chat")) {
|
rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||||
Analytics.Companion.getShared().track("Loki Public Chat Opened");
|
int height = rootView.getRootView().getHeight() - rootView.getHeight();
|
||||||
} else {
|
expandedKeyboardHeight = Math.max(expandedKeyboardHeight, height);
|
||||||
Analytics.Companion.getShared().track("RSS Feed Opened");
|
collapsedKeyboardHeight = Math.min(collapsedKeyboardHeight, height);
|
||||||
}
|
keyboardHeight = Math.max(expandedKeyboardHeight - collapsedKeyboardHeight, keyboardHeight);
|
||||||
} else {
|
});
|
||||||
Analytics.Companion.getShared().track("Conversation Opened");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1173,7 +1173,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private void handleAddAttachment() {
|
private void handleAddAttachment() {
|
||||||
if (this.isMmsEnabled || isSecureText) {
|
if (this.isMmsEnabled || isSecureText) {
|
||||||
if (attachmentTypeSelector == null) {
|
if (attachmentTypeSelector == null) {
|
||||||
attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener());
|
attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener(), keyboardHeight);
|
||||||
}
|
}
|
||||||
attachmentTypeSelector.show(this, attachButton);
|
attachmentTypeSelector.show(this, attachButton);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user