Skip to content

Commit

Permalink
feat: hide title
Browse files Browse the repository at this point in the history
close #188

Signed-off-by: qwq233 <qwq233@qwq2333.top>
  • Loading branch information
qwq233 committed Jan 20, 2024
1 parent 284f94f commit fe8c6a1
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 1 deletion.
22 changes: 22 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private ActionBarMenuItem.Item muteItem;
private ActionBarMenuItem.Item muteItemGap;
private ChatNotificationsPopupWrapper chatNotificationsPopupWrapper;
private ActionBarMenuSubItem hideTitleItem;
private float pagedownButtonEnterProgress;
private float mentionsButtonEnterProgress;
private float reactionsMentionButtonEnterProgress;
Expand Down Expand Up @@ -1401,6 +1402,7 @@ public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolea
private final static int bot_settings = 31;
private final static int call = 32;
private final static int video_call = 33;
private final static int hide_title = 102;

private final static int delete_history = 101;

Expand Down Expand Up @@ -3514,6 +3516,17 @@ public void run(boolean revoke) {
// Bundle bundle = new Bundle();
// bundle.putLong("chat_id", -dialog_id);
// presentFragment(new TopicsFragment(bundle));
} else if (id == hide_title) {
Config.toggleHideTitle();
updateTitle(false);
checkAndUpdateAvatar();
if (hideTitleItem != null) {
if (Config.hideTitle) {
hideTitleItem.setText(LocaleController.getString("ShowTitle", R.string.ShowTitle));
} else {
hideTitleItem.setText(LocaleController.getString("HideTitle", R.string.HideTitle));
}
}
}
}
});
Expand Down Expand Up @@ -3812,6 +3825,15 @@ public void toggleMute() {
if (themeDelegate.isThemeChangeAvailable(true)) {
headerItem.lazilyAddSubItem(change_colors, R.drawable.msg_colors, LocaleController.getString("SetWallpapers", R.string.SetWallpapers));
}
if (Config.showHideTitle) {
String hideTitleString = "";
if (Config.hideTitle) {
hideTitleString = LocaleController.getString("ShowTitle", R.string.ShowTitle);
} else {
hideTitleString = LocaleController.getString("HideTitle", R.string.HideTitle);
}
hideTitleItem = headerItem.addSubItem(hide_title, R.drawable.hide_title, hideTitleString, themeDelegate);
}
if (!isTopic) {
clearHistoryItem = headerItem.lazilyAddSubItem(clear_history, R.drawable.msg_clear, LocaleController.getString("ClearHistory", R.string.ClearHistory));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@

import java.util.concurrent.atomic.AtomicReference;

import top.qwq2333.gen.Config;

public class ChatAvatarContainer extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {

public boolean allowDrawStories;
Expand Down Expand Up @@ -1132,6 +1134,12 @@ public void checkAndUpdateAvatar() {
}
avatarImageView.setRoundRadius(chat.forum ? AndroidUtilities.dp(16) : AndroidUtilities.dp(21));
}

int visibility = Config.hideTitle
? android.view.View.GONE
: android.view.View.VISIBLE;
avatarImageView.setVisibility(visibility);
titleTextView.setVisibility(visibility);
}

public void updateOnlineCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public class ChatSettingActivity extends BaseActivity {
private int scrollableChatPreviewRow;
private int showTabsOnForwardRow;
private int disableStickersAutoReorderRow;
private int hideTitleRow;
private int chat2Row;

private int markdownRow;
Expand Down Expand Up @@ -354,6 +355,11 @@ protected void onItemClick(View view, int position, float x, float y) {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(Config.markdownDisabled);
}
} else if (position == hideTitleRow) {
Config.toggleShowHideTitle();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(Config.showHideTitle);
}
}

}
Expand Down Expand Up @@ -405,6 +411,7 @@ protected void updateRows() {
scrollableChatPreviewRow = addRow("scrollableChatPreview");
showTabsOnForwardRow = addRow("showTabsOnForward");
disableStickersAutoReorderRow = addRow("disableStickersAutoReorder");
hideTitleRow = addRow("showHideTitle");
chat2Row = addRow();
markdownRow = addRow();
markdownDisableRow = addRow("markdownDisabled");
Expand Down Expand Up @@ -539,6 +546,8 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, boole
textCell.setTextAndCheck(LocaleController.getString("MarkdownParseLinks", R.string.MarkdownParseLinks), Config.markdownParseLinks, false);
} else if (position == markdownDisableRow) {
textCell.setTextAndCheck(LocaleController.getString("MarkdownDisableByDefault", R.string.MarkdownDisableByDefault), Config.markdownDisabled, true);
} else if (position == hideTitleRow) {
textCell.setTextAndCheck(LocaleController.getString("showHideTitle", R.string.showHideTitle), Config.showHideTitle, true);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ object Defines {
@BooleanConfig const val showExactTime = "showExactTime"
@BooleanConfig const val hideStories = "hideStories"
@BooleanConfig const val storyStealthMode = "storyStealthMode"
@BooleanConfig const val ignoreUserSpecifiedReplyColor = "ignoreUserSpecifiedReplyColor";
@BooleanConfig const val ignoreUserSpecifiedReplyColor = "ignoreUserSpecifiedReplyColor"
@BooleanConfig const val hideTitle = "hideTitle"
@BooleanConfig const val showHideTitle = "showHideTitle"

/**
* 0 default 1 online 2 offline
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions TMessagesProj/src/main/res/values/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,7 @@
<string name="CreateCodeLanguage">Language</string>
<string name="UnsupportedMediaNullgram">This message is not supported on your version of Nullgram. Update the app to view: https://t.me/NullgramClient</string>
<string name="ignoreUserSpecifiedReplyColor">Ignore user-set reply color</string>
<string name="ShowTitle">Show title</string>
<string name="HideTitle">Hide title</string>
<string name="showHideTitle">Show hide title</string>
</resources>

0 comments on commit fe8c6a1

Please sign in to comment.