Skip to content

Commit

Permalink
refactor: Disable Bottom Bar In Channels
Browse files Browse the repository at this point in the history
thanks to OctoGram and NagramX, ported from Nagram

Co-authored-by: nick <[email protected]>
Co-authored-by: risin42 <[email protected]>
  • Loading branch information
3 people authored and NextAlone committed Jan 17, 2025
1 parent 49a4b0f commit 7e5db69
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,8 @@ public void run() {
private final static int OPTION_FACT_CHECK = 106;
private final static int OPTION_EDIT_PRICE = 107;

private boolean isChannelBottomMuteView = false;

private final static int[] allowedNotificationsDuringChatListAnimations = new int[]{
NotificationCenter.messagesRead,
NotificationCenter.threadMessagesRead,
Expand Down Expand Up @@ -9850,10 +9852,15 @@ private void createUndoView() {
return;
}
undoView = new UndoView(getContext(), this, false, themeDelegate);
undoView.setAdditionalTranslationY(AndroidUtilities.dp(51));
undoView.setAdditionalTranslationY(isBottomOverlayHidden() ? 0 : AndroidUtilities.dp(51));
contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
}

private boolean isBottomOverlayHidden() {
// na: DisableChannelMuteButton
return currentChat != null && Config.disableChannelMuteButton && isChannelBottomMuteView && !currentChat.creator && !ChatObject.canWriteToChat(currentChat);
}

@Override
public INavigationLayout.BackButtonState getBackButtonState() {
return INavigationLayout.BackButtonState.BACK;
Expand Down Expand Up @@ -11809,7 +11816,7 @@ private void invalidateChatListViewTopPadding() {
bottomMessagesActionContainer.setTranslationY(bottomPanelTranslationYReverse);
}
if (undoView != null) {
undoView.setAdditionalTranslationY(chatActivityEnterView.getHeightWithTopView() - chatActivityEnterView.getAnimatedTop());
undoView.setAdditionalTranslationY(chatActivityEnterView.getHeightWithTopView() - chatActivityEnterView.getAnimatedTop() - (isBottomOverlayHidden() ? AndroidUtilities.dp(51) : 0));
}
if (messagesSearchListContainer != null) {
messagesSearchListContainer.setTranslationY(getHashtagTabsHeight() + contentPanTranslation);
Expand Down Expand Up @@ -17552,6 +17559,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
} else if (child == chatListView || child == chatListThanosEffect) {
int contentWidthSpec = View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY);
int h = heightSize - listViewTopHeight - (inPreviewMode && Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + blurredViewTopOffset + blurredViewBottomOffset;
h += (isBottomOverlayHidden() ? AndroidUtilities.dp(51) : 0);
if (keyboardSize > AndroidUtilities.dp(20) && getLayoutParams().height < 0 && !isInsideContainer) {
h += keyboardSize;
}
Expand Down Expand Up @@ -17772,6 +17780,9 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (!inPreviewMode) {
childTop -= chatActivityEnterView.getMeasuredHeight();
}
if (isBottomOverlayHidden()) {
childTop += AndroidUtilities.dp(51);
}
} else if (child == emptyViewContainer) {
childTop -= inputFieldHeight / 2 - (actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() / 2 : 0);
} else if (chatActivityEnterView.isPopupView(child)) {
Expand Down Expand Up @@ -26151,6 +26162,7 @@ private void updateBottomOverlay() {
bottomOverlayChatWaitsReply = false;
bottomOverlayLinks = false;
boolean forceNoBottom = false;
boolean tempMuteView = false;
if (chatMode == MODE_DEFAULT && getDialogId() != getUserConfig().getClientUserId() && userInfo != null && userInfo.contact_require_premium && !getUserConfig().isPremium()) {
bottomOverlayLinks = true;
bottomOverlayChatText.setVisibility(View.GONE);
Expand Down Expand Up @@ -26198,6 +26210,7 @@ private void updateBottomOverlay() {
}
showBottomOverlayProgress(false, false);
} else if (currentUser != null && currentUser.id == UserObject.VERIFY) {
tempMuteView = true;
if (!getMessagesController().isDialogMuted(dialog_id, getTopicId())) {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelMute), false);
bottomOverlayChatText.setEnabled(true);
Expand Down Expand Up @@ -26235,17 +26248,18 @@ private void updateBottomOverlay() {
bottomOverlayChatText.setTextInfo(LocaleController.getString(R.string.ForumReplyToMessagesInTopic));
bottomOverlayChatText.setEnabled(false);
} else if (!isThreadChat()) {
tempMuteView = true;
if (!getMessagesController().isDialogMuted(dialog_id, getTopicId())) {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelMute), false);
bottomOverlayChatText.setEnabled(true);
} else {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelUnmute), true);
bottomOverlayChatText.setEnabled(true);
}
if (Config.disableChannelMuteButton) {
bottomOverlayChatText.setText("", false);
bottomOverlayChatText.setEnabled(false);
}
// if (Config.disableChannelMuteButton) {
// bottomOverlayChatText.setText("", false);
// bottomOverlayChatText.setEnabled(false);
// }
showBottomOverlayProgress(false, bottomOverlayProgress.getTag() != null);
} else if (forumTopic != null && forumTopic.closed) {
if (!ChatObject.canManageTopic(currentAccount, currentChat, forumTopic)) {
Expand Down Expand Up @@ -26291,6 +26305,7 @@ private void updateBottomOverlay() {
}
}
} else if (UserObject.isReplyUser(currentUser)) {
tempMuteView = true;
if (!getMessagesController().isDialogMuted(dialog_id, getTopicId())) {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelMute), false);
} else {
Expand All @@ -26316,6 +26331,8 @@ private void updateBottomOverlay() {
}
}

isChannelBottomMuteView = tempMuteView;

if (currentChat != null && currentChat.gigagroup && !isReport() && chatMode == 0) {
bottomOverlayImage.setVisibility(View.VISIBLE);
} else {
Expand All @@ -26328,6 +26345,10 @@ private void updateBottomOverlay() {
bottomOverlayChat.setVisibility(View.INVISIBLE);
chatActivityEnterView.setFieldFocused(false);
chatActivityEnterView.setVisibility(View.INVISIBLE);
} else if (isBottomOverlayHidden()) {
bottomOverlayChat.setVisibility(View.INVISIBLE);
chatActivityEnterView.setFieldFocused(false);
chatActivityEnterView.setVisibility(View.INVISIBLE);
} else if (bottomOverlayLinks) {
bottomOverlayChat.setVisibility(View.VISIBLE);
chatActivityEnterView.setVisibility(View.INVISIBLE);
Expand Down Expand Up @@ -28415,7 +28436,7 @@ public int getBottomOffset(int tag) {
height += translationY;
}
height += contentPanTranslation;
return height - AndroidUtilities.dp(1.5f);
return height - AndroidUtilities.dp(1.5f) - (isBottomOverlayHidden() ? AndroidUtilities.dp(51) : 0);
}

@Override
Expand Down

0 comments on commit 7e5db69

Please sign in to comment.