mirror of https://github.com/NekoX-Dev/NekoX.git
48 lines
2.3 KiB
Java
48 lines
2.3 KiB
Java
package org.telegram.ui.Components;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
|
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
|
|
|
|
public class ChatScrimPopupContainerLayout extends LinearLayout {
|
|
|
|
public ReactionsContainerLayout reactionsLayout;
|
|
public ActionBarPopupWindow.ActionBarPopupWindowLayout popupWindowLayout;
|
|
|
|
public ChatScrimPopupContainerLayout(Context context) {
|
|
super(context);
|
|
setOrientation(LinearLayout.VERTICAL);
|
|
}
|
|
|
|
@Override
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
if (reactionsLayout != null && popupWindowLayout != null) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
int reactionsLayoutTotalWidth = reactionsLayout.getTotalWidth();
|
|
View menuContainer = popupWindowLayout.getSwipeBack() != null ? popupWindowLayout.getSwipeBack().getChildAt(0) : popupWindowLayout.getChildAt(0);
|
|
int maxReactionsLayoutWidth = menuContainer.getMeasuredWidth() + AndroidUtilities.dp(16) + AndroidUtilities.dp(16) + AndroidUtilities.dp(36);
|
|
if (reactionsLayoutTotalWidth > maxReactionsLayoutWidth) {
|
|
int maxFullCount = ((maxReactionsLayoutWidth - AndroidUtilities.dp(16)) / AndroidUtilities.dp(36)) + 1;
|
|
int newWidth = maxFullCount * AndroidUtilities.dp(36) + AndroidUtilities.dp(16) - AndroidUtilities.dp(8);
|
|
if (newWidth > reactionsLayoutTotalWidth || maxFullCount == reactionsLayout.getItemsCount()) {
|
|
newWidth = reactionsLayoutTotalWidth;
|
|
}
|
|
reactionsLayout.getLayoutParams().width = newWidth;
|
|
} else {
|
|
reactionsLayout.getLayoutParams().width = LayoutHelper.WRAP_CONTENT;
|
|
}
|
|
int widthDiff = 0;
|
|
if (popupWindowLayout.getSwipeBack() != null) {
|
|
widthDiff = popupWindowLayout.getSwipeBack().getMeasuredWidth() - popupWindowLayout.getSwipeBack().getChildAt(0).getMeasuredWidth();
|
|
}
|
|
((LayoutParams)reactionsLayout.getLayoutParams()).rightMargin = widthDiff;
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
} else {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
}
|
|
}
|
|
}
|