Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 committed Dec 22, 2024
2 parents 8d04ce7 + d5b4148 commit 4aef86d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public void setOpenBotButton(boolean show) {
private boolean allowBotOpenButton;
private Utilities.Callback<TLRPC.User> onOpenButtonClick;
public DialogCell allowBotOpenButton(boolean allow, Utilities.Callback<TLRPC.User> onOpenClick) {
allowBotOpenButton = allow;
allowBotOpenButton = allow && !NaConfig.INSTANCE.getDisableBotOpenButton().Bool();
onOpenButtonClick = onOpenClick;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import java.util.Locale;

import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.MessageHelper;

public class ProfileSearchCell extends BaseCell implements NotificationCenter.NotificationCenterDelegate, Theme.Colorable {
Expand Down Expand Up @@ -152,7 +153,7 @@ public ProfileSearchCell(Context context, Theme.ResourcesProvider resourcesProvi
private boolean allowBotOpenButton;
private Utilities.Callback<TLRPC.User> onOpenButtonClick;
public ProfileSearchCell allowBotOpenButton(boolean allow, Utilities.Callback<TLRPC.User> onOpenClick) {
allowBotOpenButton = allow;
allowBotOpenButton = allow && !NaConfig.INSTANCE.getDisableBotOpenButton().Bool();
onOpenButtonClick = onOpenClick;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3376,7 +3376,12 @@ public boolean canToggleSearch() {
} else {
statusDrawable = new AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable(null, dp(26));
statusDrawable.center = true;
actionBar.setTitle(NaConfig.INSTANCE.getCustomTitle().String(), statusDrawable);
String title = NaConfig.INSTANCE.getCustomTitle().String();
if (NaConfig.INSTANCE.getCustomTitleUserName().Bool()) {
TLRPC.User self = UserConfig.getInstance(currentAccount).getCurrentUser();
if (self != null && self.first_name != null) title = self.first_name;
}
actionBar.setTitle(title, statusDrawable);
actionBar.setOnLongClickListener(v -> {
if (NekoConfig.hideAllTab.Bool() && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) {
filterTabsView.toggleAllTabs(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class ConfigCellTextInput extends AbstractConfigCell {
private final ConfigItem bindConfig;
private final String hint;
private final String title;
private boolean enabled = true;
public TextSettingsCell cell;
private final Runnable onClickCustom;
private final Function<String, String> inputChecker;

Expand Down Expand Up @@ -60,15 +62,25 @@ public String getKey() {
}

public boolean isEnabled() {
return true;
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
if (this.cell != null)
this.cell.setEnabled(this.enabled, null);
}

public void onBindViewHolder(RecyclerView.ViewHolder holder) {
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
this.cell = cell;
cell.setTextAndValue(title, bindConfig.String(), cellGroup.needSetDivider(this));
cell.setCanDisable(true);
cell.setEnabled(enabled, null);
}

public void onClick() {
if (!enabled) return;
if (onClickCustom != null) {
try {
onClickCustom.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen
private final AbstractConfigCell showQuickReplyInBotCommandsRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowQuickReplyInBotCommands()));
private final AbstractConfigCell disablePreviewVideoSoundShortcutRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisablePreviewVideoSoundShortcut(), LocaleController.getString(R.string.DisablePreviewVideoSoundShortcutNotice)));
private final AbstractConfigCell showTimeHintRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowTimeHint()));
private final AbstractConfigCell disableBotOpenButtonRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableBotOpenButton()));
private final AbstractConfigCell dividerInteractions = cellGroup.appendCell(new ConfigCellDivider());

// Sticker
Expand Down Expand Up @@ -354,6 +355,8 @@ public void onItemClick(int id) {
MediaController.getInstance().recreateProximityWakeLock();
} else if (key.equals(NekoConfig.showSeconds.getKey())) {
tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
} else if (key.equals(NaConfig.INSTANCE.getDisableBotOpenButton().getKey())) {
tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public class NekoGeneralSettingsActivity extends BaseNekoXSettingsActivity {
private final AbstractConfigCell customSavePathRow = cellGroup.appendCell(new ConfigCellTextInput(null, NekoConfig.customSavePath,
LocaleController.getString("customSavePathHint", R.string.customSavePathHint), null,
(input) -> input.matches("^[A-za-z0-9.]{1,255}$") || input.isEmpty() ? input : (String) NekoConfig.customSavePath.defaultValue));
private final AbstractConfigCell customTitleUserNameRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getCustomTitleUserName()));
private final AbstractConfigCell useSystemUnlockRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getUseSystemUnlock()));
private final AbstractConfigCell disableUndoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableUndo));
private final AbstractConfigCell showIdAndDcRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showIdAndDc));
Expand Down Expand Up @@ -504,6 +505,11 @@ public void onItemClick(int id) {
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
} else if (key.equals(NaConfig.INSTANCE.getSentryAnalytics().getKey())) {
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
} else if (key.equals(NaConfig.INSTANCE.getCustomTitleUserName().getKey())) {
boolean enabled = (Boolean) newValue;
((ConfigCellTextInput) customTitleRow).setEnabled(!enabled);
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(customTitleRow));
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
}
};

Expand Down Expand Up @@ -895,6 +901,9 @@ private void setCanNotChange() {
if (NekoConfig.useOSMDroidMap.Bool())
((ConfigCellTextCheck) mapDriftingFixForGoogleMapsRow).setEnabled(false);

if (NaConfig.INSTANCE.getCustomTitleUserName().Bool())
((ConfigCellTextInput) customTitleRow).setEnabled(false);

if (NekoConfig.useTelegramTranslateInChat.Bool())
((ConfigCellCustom) translationProviderRow).setEnabled(false);

Expand Down
12 changes: 12 additions & 0 deletions TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,18 @@ object NaConfig {
ConfigItem.configTypeInt,
0
)
val disableBotOpenButton =
addConfig(
"DisableBotOpenButton",
ConfigItem.configTypeBool,
false
)
val customTitleUserName =
addConfig(
"CustomTitleUserName",
ConfigItem.configTypeBool,
false
)

private fun addConfig(
k: String,
Expand Down
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 @@ -167,4 +167,6 @@
<string name="SendWithPangu">使用 Pangu 发送</string>
<string name="SendWithoutPangu">不使用 Pangu 发送</string>
<string name="DefaultHlsVideoQuality">默认 Hls 视频质量</string>
<string name="DisableBotOpenButton">禁用 Bot 的打开小程序按钮</string>
<string name="CustomTitleUserName">使用用户昵称作为标题</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 @@ -168,4 +168,6 @@
<string name="SendWithPangu">Send with Pangu</string>
<string name="SendWithoutPangu">Send without Pangu</string>
<string name="DefaultHlsVideoQuality">Default Hls Video Quality</string>
<string name="DisableBotOpenButton">Disable Bot Open Button</string>
<string name="CustomTitleUserName">Use user nickname as Title</string>
</resources>

0 comments on commit 4aef86d

Please sign in to comment.