Skip to content

Commit

Permalink
feat: option for disabling markdown (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruattd committed Feb 9, 2024
1 parent 93394e3 commit 63db0d1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4607,14 +4607,19 @@ public void didSelectDate(boolean notify, int scheduleDate) {
}
if (sendWithoutSoundButtonValue) {
if (containsMarkdown(messageEditText.getText())) {
boolean withoutMarkdown = NaConfig.INSTANCE.getDisableMarkdown().Bool();
ActionBarMenuSubItem sendWithoutMarkdownButton = new ActionBarMenuSubItem(getContext(), false, false, resourcesProvider);
sendWithoutMarkdownButton.setTextAndIcon(LocaleController.getString("SendWithoutMarkdown", R.string.SendWithoutMarkdown), R.drawable.round_code_off_white);
if (withoutMarkdown) {
sendWithoutMarkdownButton.setTextAndIcon(LocaleController.getString("SendWithMarkdown", R.string.SendWithMarkdown), R.drawable.round_code_white);
} else {
sendWithoutMarkdownButton.setTextAndIcon(LocaleController.getString("SendWithoutMarkdown", R.string.SendWithoutMarkdown), R.drawable.round_code_off_white);
}
sendWithoutMarkdownButton.setMinimumWidth(AndroidUtilities.dp(196));
sendWithoutMarkdownButton.setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
sendMessageInternal(true, 0, true, false, true);
sendMessageInternal(true, 0, true, withoutMarkdown, true);
});
sendPopupLayout.addView(sendWithoutMarkdownButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
} else if (canSendAsDice(messageEditText.getText().toString(), parentFragment, dialog_id)) {
Expand All @@ -4625,7 +4630,7 @@ public void didSelectDate(boolean notify, int scheduleDate) {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
sendMessageInternal(true, 0, true, true, false);
sendMessageInternal(true, 0, true, null, false);
});
sendPopupLayout.addView(sendWithoutMarkdownButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
}
Expand Down Expand Up @@ -7024,10 +7029,14 @@ public void didSelectDate(boolean notify, int scheduleDate) {
private boolean premiumEmojiBulletin = true;

private void sendMessageInternal(boolean notify, int scheduleDate, boolean allowConfirm) {
sendMessageInternal(notify, scheduleDate, allowConfirm, true, true);
sendMessageInternal(notify, scheduleDate, allowConfirm, null, true);
}

private void sendMessageInternal(boolean notify, int scheduleDate, boolean allowConfirm, boolean withMarkdown, boolean withGame) {
private void sendMessageInternal(boolean notify, int scheduleDate, boolean allowConfirm, Boolean withMarkdown, boolean withGame) {
boolean disableMarkdown = NaConfig.INSTANCE.getDisableMarkdown().Bool();
if (withMarkdown == null) {
withMarkdown = !disableMarkdown;
}
if (slowModeTimer == Integer.MAX_VALUE && !isInScheduleMode()) {
if (delegate != null) {
delegate.scrollToSendingMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen
private final AbstractConfigCell showSendAsUnderMessageHintRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowSendAsUnderMessageHint()));
private final AbstractConfigCell hideBotButtonInInputFieldRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getHideBotButtonInInputField()));
private final AbstractConfigCell doNotUnarchiveBySwipeRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDoNotUnarchiveBySwipe()));
private final AbstractConfigCell disableMarkdownRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableMarkdown()));
private final AbstractConfigCell dividerInteractions = cellGroup.appendCell(new ConfigCellDivider());

// Sticker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ object NaConfig {
ConfigItem.configTypeInt,
0
)
val disableMarkdown =
addConfig(
"DisableMarkdown",
ConfigItem.configTypeBool,
false
)

private fun addConfig(
k: String,
Expand Down
5 changes: 5 additions & 0 deletions TMessagesProj/src/main/res/drawable/round_code_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="28dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="28dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M8.7,15.9L4.8,12l3.9,-3.9c0.39,-0.39 0.39,-1.01 0,-1.4 -0.39,-0.39 -1.01,-0.39 -1.4,0l-4.59,4.59c-0.39,0.39 -0.39,1.02 0,1.41l4.59,4.6c0.39,0.39 1.01,0.39 1.4,0 0.39,-0.39 0.39,-1.01 0,-1.4zM15.3,15.9l3.9,-3.9 -3.9,-3.9c-0.39,-0.39 -0.39,-1.01 0,-1.4 0.39,-0.39 1.01,-0.39 1.4,0l4.59,4.59c0.39,0.39 0.39,1.02 0,1.41l-4.59,4.6c-0.39,0.39 -1.01,0.39 -1.4,0 -0.39,-0.39 -0.39,-1.01 0,-1.4z"/>
</vector>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@
<string name="ExternalStickerCacheDeleteAll">删除所有缓存</string>
<string name="ExternalStickerCacheDirNameType">目录命名方式</string>
<string name="ProviderTranSmartTranslate">腾讯交互翻译</string>
<string name="DisableMarkdown">禁用 Markdown</string>
<string name="SendWithMarkdown">启用 Markdown</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@
<string name="ExternalStickerCacheDeleteAll">Delete all caches</string>
<string name="ExternalStickerCacheDirNameType">Directory naming</string>
<string name="ProviderTranSmartTranslate">TranSmart Translator</string>
<string name="DisableMarkdown">Disable Markdown</string>
<string name="SendWithMarkdown">Send with markdown</string>
</resources>

0 comments on commit 63db0d1

Please sign in to comment.